Question
Java Write a program that will read a file of text and produce a list of all the unique words in the text and their
Java
Write a program that will read a file of text and produce a list of all the unique words in the text and their frequency of occurrence; in order from most frequent to least frequent. The output will be to an ASCIIDisplayer. For example, the concordance of the file AlicesAdventuresInWonderland.txt (the Project Gutenberg version) [This is a text file which included an article]
Your program should read the text file and create a sequentially-linked structure of the unique words in the text with their frequency of occurrence. It should then move the words from this list to a new sequentially-linked structure in which the words are in descending order by frequency. It should then list the words in the sorted list to an ASCIIDisplayer with the frequency followed by the word
When a new WordReader is created, it opens an ASCIIDataFile. Each time readWord is called, it returns the next word (sequence of alphabetic characters) as a String. When EOF is reached, the method isEOF returns true. The reader is closed via a call to the method close. This class should not be modified (except, perhaps, changing the package declaration.) The words should be represented by a class Word that includes the word itself (i.e. a String) and the frequency of occurrence of the word (an int). The class should have appropriate accessor, updater and mutator methods for the problem. The Node class should be the usual with the items being objects of type Word. The unique words list should be a sequentially-linked structure in any order containing only unique words (i.e. no duplicates). Since words at the beginning of a sentence are capitalized but elsewhere are not capitalized, uniqueness should not be case sensitive (i.e. The and the should be considered as the same word.) The String method equalsIgnoreCase can be used for this check. The sorted word list should be created by removing the Word objects from the unique list and adding them in descending sorted (by frequency of occurrence) order into the sorted list. The sorted list should then be traversed to write the frequencies and words to the display.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started