Skip to content

Your goal is to write a Python function that determines the number of unique words in a text file, and counts how many times each word occurs.

License

Notifications You must be signed in to change notification settings

hr21don/The-Voyage-Of-Vanishing-Men

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

The-Voyage-Of-Vanishing-Men

Your goal is to write a Python function that determines the number of unique words in a text file, and counts how many times each word occurs.

Input

It should accept the path to a text file as the input argument, and then print the total number of words in the file, as well as the top 20 most frequently used words and how many times each of them occurs.

Words Contain

We'll say that words can contain letters, numbers, apostrophes and hyphens, and they're separated by any other punctuation or white space.

Output

For e.g.

  • from UniqueWords import unique_words
  • unique_words('StanleyMullen.txt')

Total Worlds: 743

Top 20 words: AND 29 THE 29 A 26 WAS 15 TO 14 YOU 13 HE 12 OF 11 BRAUN 11 THERE 11 IN 11 ABOUT 11 IT 10 OUT 9 AS 9 I 8 HAD 7 INTO 7 TALK 6 ON 6

Testing

For testing purposes, grab sample text from https://www.gutenberg.org/ebooks/66572 to form your txt file. The Project Gutenberg eBook of The Voyage of Vanishing Men, by Stanley Mullen is a good starting point ( Date Accessed: Oct 19, 2021).

About

Your goal is to write a Python function that determines the number of unique words in a text file, and counts how many times each word occurs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages