Question: JAVA - 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

JAVA - 

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 dont 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

SpellCheck.java /** * Write a description of class ReadFiles here. * * @author (your name) * @version (a version number or a date) */ import java.util.*; import java.io.*; public class SpellCheck { HashSet dictionary = new HashSet(); ArrayList story = new ArrayList(); public void storeDictionaryAndStory() { Scanner reader=null; try { reader = new Scanner(new File("EnglishWordList.txt")); } catch ( FileNotFoundException ex) {System.out.println(ex+" file not found "); } while (reader.hasNext()){ String str = reader.next(); str = str.replaceAll("[\\[\\]_:\"'`?;\\0-9;()-/.,*! ]", "").toLowerCase(); dictionary.add(str); } try { reader = new Scanner(new File("WinnieThePoohStories.txt")); } catch ( FileNotFoundException ex) {System.out.println(ex+" file not found "); } while (reader.hasNext()){ String str = reader.next(); str = str.replaceAll("[\\[\\]_:\"'`?;\\0-9;()-/.,*! ]", "").toLowerCase(); if (!str.isEmpty())story.add(str); } } public void printStats() { } } }

automotive5.txt

{"reviewerID": "A3ESWJPAVRPWB4", "asin": "B00002243X", "reviewerName": "E. Hernandez", "helpful": [0, 0], "reviewText": "I purchased the 12' feet long cable set and they arrived in a retail cardboard box with handle, which could be used as a storage and carrying case for these cables, although I will not need to store them with the carry box. These are high quality long cables of high grade materials and I believe worth the price I paid for them. They will store in the back seat storage compartment of my truck easily. Recomend.", "overall": 5.0, "summary": "Excellent, High Quality Starter Cables", "unixReviewTime": 1341360000, "reviewTime": "07 4, 2012"} {"reviewerID": "A1ORODEBRN64C", "asin": "B00002243X", "reviewerName": "James F. Magowan \"Jimmy Mac\"", "helpful": [1, 1], "reviewText": "These Jumper cables are heavy Duty, Yet easy to Store. I keep them in one of my containers on my delivery vehicle. They are high quality. They are 4 gauge cable, so they are perfect and long enough to Start are Utilimaster Diesel trucks when are batteries are run Down. There are more expensive cables and even more sever duty use cables. these are perfect for this type of vehicle in an Emergency. The cost is reasonable as well. With 25 feet, you don't have to get real close to the other vehicle. you can pull up to the back and or side and just run the cables under or down the side of the vehicle.", "overall": 5.0, "summary": "Compact and Strong !", "unixReviewTime": 1258156800, "reviewTime": "11 14, 2009"} {"reviewerID": "A2R49ZN3G6FTCQ", "asin": "B00002243X", "reviewerName": "John M. Harrell", "helpful": [1, 1], "reviewText": "bought these for my k2500 suburban plenty of length front to rear. i ended up using them right out of the box as i for a dead battery in my truck. they worked great. several people have complained about the clamps. they worked well for me and i had no issues with poor connections. cables are well made.", "overall": 5.0, "summary": "nice cables", "unixReviewTime": 1326153600, "reviewTime": "01 10, 2012"}

EnglishWordList.txt

http://www-personal.umich.edu/~jlawler/wordlist

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!