Use the text file (in UTF-8 format) Automotive_5.txt for this exercise. Your fir
ID: 3721231 • Letter: U
Question
Use the text file (in UTF-8 format) Automotive_5.txt for this exercise. Your first goal is to find all words in the text file that are good in the dictionary (ignore the rest) and also count the frequency of occurrence of each such word in the text file. You will convert every word into lowercase and get rid of punctuations if present. Your code thus far, should run in O(n) time where n is the number of words in the txt file. Your helper files are EnglishWordList.txt and SpellCheck.java. You can do this exercise by making changes/additions to SpellCheck.java code. But you only need to make small number of changes to the code. So don’t overthink this. Add code for the additional method public void printStats() that prints the word with the highest frequency, the word with the lowest frequency, the frequency counts of each and the total number of words. For example, your output could be like this:
Total number of good words is equal to “count”
automotive5.txt
EnglishWordList.txt
http://www-personal.umich.edu/~jlawler/wordlist
Explanation / Answer
The code referred doesn't mention anything about the WinnieThePoohStories.txt, so I'm assuming it is the automotive_5.txt file.
With that assumption the above results can be achieved in Java as:
Output
The highest frequent word is 'are', and its frequency is 11
The lowest frequent word is 'carrying', and its frequency is 1
The total number of good words is equal to 48
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.