Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds word count example over Shakespear/Jane Austen works #140

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ttomsu
Copy link

@ttomsu ttomsu commented Aug 25, 2024

#80

This sample concurrently reads multiple works concurrently and counts their unique words per work. Then, it combines all counts for a final total count. This sample uses pool.NewWithResults, stream.Stream, and iter.ForEach

Sample output:

2024/08/25 14:35:15 INFO Done counting words work=midsummernightsdream.txt duration=5.530375ms
2024/08/25 14:35:15 INFO Done counting words work=hamlet.txt duration=11.226209ms
2024/08/25 14:35:15 INFO Done counting words work=othello.txt duration=9.21525ms
2024/08/25 14:35:15 INFO Done counting words work=romeoandjuliet.txt duration=7.035209ms
2024/08/25 14:35:15 INFO Done counting words work=emma.txt duration=36.980125ms
2024/08/25 14:35:15 INFO Done counting words work=prideandprejudice.txt duration=28.536667ms
2024/08/25 14:35:15 INFO Done counting words work=tamingoftheshrew.txt duration=4.351709ms
2024/08/25 14:35:15 INFO Done counting words work=senseandsensibility.txt duration=24.007125ms
2024/08/25 14:35:15 INFO unique words=4822 mostCommonWord=the mostCommonCount=482
2024/08/25 14:35:15 INFO unique words=7807 mostCommonWord=the mostCommonCount=929
2024/08/25 14:35:15 INFO unique words=7425 mostCommonWord=I mostCommonCount=830
2024/08/25 14:35:15 INFO unique words=6868 mostCommonWord=the mostCommonCount=685
2024/08/25 14:35:15 INFO unique words=18022 mostCommonWord=to mostCommonCount=5108
2024/08/25 14:35:15 INFO unique words=13778 mostCommonWord=the mostCommonCount=4220
2024/08/25 14:35:15 INFO unique words=5462 mostCommonWord=I mostCommonCount=601
2024/08/25 14:35:15 INFO unique words=14289 mostCommonWord=the mostCommonCount=4150
2024/08/25 14:35:15 INFO Done with all word counts in=51.901166ms totalUniqueWords=46530 mostCommonWord=the mostCommonCount=16592

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant