Question: This assignment is to write a java program to do the following: Determine the number of unique words she used (in a provided collection of
This assignment is to write a java program to do the following:
- Determine the number of unique words she used (in a provided collection of her works).
- Compare the time required to determine this number across several different algorithms
- Determine the three most common words in this collection and how many times each occurs.
Get the files: ProbeHTInc.java, Map206.java, Map206Interface.java, SepChainHT.java
- Write a class -- perhaps named MyReader with the following suggested properties (innovation is encouraged):
- It takes a single arguement in its constructor. That arguement is the name of the a file (probably either "ham.txt" or "janeausten.txt").
- It has a single public method nextWord() which returns the next word from the file. When all words have been read, the nextWord should return null. So, the use of this class would be something like: MyReader myreader = new MyReader("ham.txt");
- As an alternative, you could give MyReader a public method nextWords() which returns an array of strings (possibly consisting of all of the words in one line of the file). When the entire file has been read, the function would return null. In this case, the code above would need to be slightly modified.
- Your MyReader class should do something to parse out common punctuation and also change everything to lower case. For instance, you might use the following: BufferedReader br; // set up as usual
- // other code here
- String line = br.readLine();
- String betterline = line.trim().toLowerCase().replaceAll("[\\.\\'?!,\\\"]", "");
- You are not required to use the above code (or even understand it), this is just an example of code that would meet this requirement.
- You must implement the get and put methods in ProbeHTInc. ("Inc" in the class name is short for incomplete.) Your implementation should use either quadratic probing. Your implementation need not be concerned with deletions and therefore does not need to use tombstones.
- You must test the speed of the following algorithms on janeausten.txt
- 206Map
- SeparateChainHT
- ProbeHTInc -- with your get and put methods
- HashMap -- from java.util
- 206Map on janeausten.txt can be expected to take several minutes.
- All programs must be runnable from the command line.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
