Using MVC Classes, OOA & OO Design and JAVA implement the Random Text Generator by using a HashMap (HashMapInterface and HashMap).

We want to generate random text in the style of another author. Your first task is to collect a group of prefix strings of two words that occur in a text file Data.txt and associate them with a list of suffix strings using a HashMap.

For example, an authors text contains the four phrases (Data.txt):

Doe was alive: to start with.
Doe was as alive as a snail.
Doe was as alive as a snail.
Doe was alive.

The prefix string Doe was would be associated with the ArrayList (Interface and ArrayList) containing the four suffix strings alive:, as, as, alive. You must go through the text (Data.txt) and examine each successive pair of two-word strings to see whether that pair is already in the HashMap as a key. If so, add the next word to the ArrayList that is the value for that prefix string. For example, in examining the first two sentences shown, you would first add the entry (Doe was, ArrayList alive:). Next you would add the entry (was alive:, ArrayList to). Next you would add the entry (alive: to, ArrayList start), and so on.

When you retrieve the prefix Doe was again, you would modify the ArrayList that is its value, and the entry would become (Doe was, LinkedList alive:, as). When you are all finished, add the entry THE_END to the suffix list for the last prefix placed in the HashMap.

At this point you need to Display the contents of the HashMap (key and the ArrayList values).

Once you have scanned the whole text (Data.txt), it is time to use the HashMap to begin generating new text that is in the same style as the old text. Output (both to the screen and to Output.txt) the first prefix you placed in the HashMap: Doe was. Then retrieve the ArrayList that is the value for this prefix. Randomly select one of the suffixes, and then Output the suffix (both to the screen and to Output.txt). For example, the output text so far might be Doe was alive if the suffix alive was selected from the ArrayList of suffixes for Doe was. Now continue with the two-word sequence consisting of the second word from the previous prefix and the suffix (that would be the string was alive:). Look it up in the HashMap, randomly select one of the suffixes, and Output it (both to the screen and to Output.txt). Continue this process until the suffix THE_END is selected.

Create a Main.java that contains the main method. Your APPLICATION must read in the data file (FILE INPUT) into your APPLICATION memory (please DO NOT read from File and write to File skipping reading into the program memory). You cannot use any DATA STRUCTURES JCL Classes! One Class per .java file! Must use MVC Design Pattern.

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.