Question: ( Optional ) TO DO # 3 : Remove the unrhymable words from the dictionary. Some words are in a rhyme group by themselves. That
Optional TO DO #: 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. Youll 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 that means theres only one word in the list: nothing rhymes with it Use Dictionaryremove to remove this entry.
If youre curious to see what words dont 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, dont forget to comment it out before you turn it in
Here are a couple of tips:
Use casting Entry to make sure object values are transformed into what you need.
Use equalskey to compare strings to each other.
Example Input and Output
RhymingDict can take or command line arguments.
The first argument is a seed for the random number generator. If you provide arguments this defaults to the current system time.
The second argument is the number of poems to generate. If or arguments are provided, this defaults to
For this command line:
java RhymingDict
the output should look like:
If I were attuned then you'd be the muggy, And we'd both be marooned and never be buggy If I were tiber then you'd be the jonas, And we'd both be fiber and never be bonus Roses are flourish, violets are deeply. I am nourish and you are steeply. Roses are learners, violets are overturn. I am burners and you are sunburn.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
