materials
materials copied to clipboard
Add word frequency counter feature
Pull Request Title
Add Word Frequency Counter Feature
Pull Request Description
What Changed
- Created a new Python script,
word_counter.py, which counts the frequency of each word in a given text file.
Why This Is Useful
- Allows users to quickly analyse text files for word usage.
- Simplifies text analysis tasks for anyone working with large amounts of textual data in the repository.
How It Works
-
word_counter.pyreads the file specified via command-line argument. - Converts all words to lowercase and splits them on whitespace.
- Uses
collections.Counterto count occurrences and sorts them in descending order. - Prints the results to the console.
Testing
- Created a sample file
sample.txtwith the content: