CST8284_521 – Assignment# 4
What to submit: WordOccurences.java
Write a program (WordOccurrences.java) that would open any text based file and writes to a file the list of unique words along with their occurrence. A word can be a combination of any number of alphanumeric characters, from 1 and up.
The program would prompt the user to enter the path to the text file, opens it, reads the content, either one line at time or else, I will leave it up to you, splits the words based on white space, stores every unique word, and count its occurrence, which would be 1 by default for every word read and then the occurrence would increment for every additional occurrence of an existing word encountered. Treat uppercase and lowercase letters the same. Ignore punctuation.
The output of this program needs to be written into a file that should hold the same name of the input file but with “_Out” tagged to the end of its name, just before the .extension; i.e. the .txt for example. So, if input file is “MyInputFile.txt”, the output file should be “MyInputFile_Out.txt”.
No need for the input file to be very large but with enough data to cover the requirements.
The alignment of the occurrence needs to be one tab (\t) past the longest word in the file read.
Make use of the Map interface 😉
Here is a sample output:
Input File content (Yours needs to be a bit longer than this)
Write a program that would open any text based file and writes to a file the list of unique words along with their occurrence. A word can be a combination of any number of characters, from 1 and up.
Output File content