Question: TO DO # 2 : Store each line from the CMU dictionary in the hashtable. This involves implementing the method storeRhyme ( ) . Use

TO DO # 2: Store each line from the CMU dictionary in the hashtable.
This involves implementing the method storeRhyme().
Use getWord() and getRhymeGroup() to get the word and rhyme group for the line.
Lookup (get) the key (the rhyme group) in the Dictionary(hashtable). If the result is null, then this rhyme group has not been added before.
Create a new MySortedLinkedList.Add the word to the list.Put the key (rhyme group) and value (list) in the Dictionary.
If the result of the lookup (get) isn't null, then we've already started a word list for this rhyme group.
Add the word to the list returned by get(). Nothing needs to be added to the Dictionary since the list is already in the Dictionary.
(Optional) TO DO #3: Remove the unrhymable words from the dictionary.
Some words are in a rhyme group by themselves. That means that nothing rhymes with them. We want to get rid of those before trying to make poems. You'll do this by implementing removeUnrhymables().
Use getKeys() to get an array of all the keys.
Iterate through all the keys, retrieving the value (linked list) associated with each key.
If the length of the list is 1, that means there's only one word in the list: nothing rhymes with it. Use Dictionary.remove() to remove this entry.
If you're curious to see what words don't have rhymes (at least according to the CMU pronunciation dictionary), you could add a println to print out the words as you remove their corresponding entries. If you do this, don't forget to comment it out before you turn it in.
TO DO # 2 : Store each line from the CMU

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 Programming Questions!