Question: Project Structure Repository: Starter code is in the HW folder 1. Clone the starter code from the repository into an IntelliJ project 2. Run Maven

Project Structure Repository: Starter code is in the HW folder 1. Clone the starter code from the repository into an IntelliJ project 2. Run Maven and make sure the src folder is marked as the source root This code provides a RhymingDictionary class that takes a filename to the pronunciation dictionary as a constructor parameter. When an object of type RhymingDictionary is created, you should parse this file and store its contents in a state variable. You will then use the state variable to complete the following objectives.

For example, all the following words from the dictionary will be considered rhymes since the last vowel is the same and all sounds after the last vowel are the same: HALF HH AE1 F PHOTOGRAPH F OW1 T AH0 G R AE2 F STAFF S T AE1 F

LAUGH L AE1 F These words also all rhyme with each other according to this definition of rhyme: THOUSAND TH AW1 Z AH0 N D DIAMOND D AY1 M AH0 N D FUND F AH1 N D AND AH0 N D SECOND S EH1 K AH0 N D ISLAND AY1 L AH0 N D LEGEND L EH1 JH AH0 N D These words do not rhyme since the sounds after the last vowel are different: DEFINE D IH0 F AY1 N RHYME R AY1 M These words do not rhyme since the sounds after the last vowel are not all identical: DIAMOND D AY1 M AH0 N D DIAMONDS D AY1 M AH0 N D Z We will also define the length of a rhyme to be the number of rhyming syllables at the end of the words. These rhymes follow the same definition of a rhyme, but extend throughout all the sounds of the work. SECOND S EH1 K AH0 N D LEGEND L EH1 JH AH0 N D Second and legend have a rhyme length of 1 since the last syllables rhyme, but the sounds between the last and second to last vowel sounds are not identical. ETCHING EH1 CH IH0 NG STRETCHING S T R EH1 CH IH0 NG Etching and stretching have a rhyme length of 2 since the last two vowel sounds are the same and all other sounds after the second to last vowel are identical. COMPUTERIZING K AH0 M P Y UW1 T ER0 AY2 Z IH0 NG THEORIZING TH IY1 ER0 AY2 Z IH0 NG Computerizing and theorizing have a rhyme length of 3 since the definition of rhyme applies to the last 3 vowel sounds, but the sounds before the third to last vowel are different. TELECREDIT T EH1 L AH0 K R EH2 D IH0 T ACCREDIT AH0 K R EH1 D IH2 T Telecredit and accredit have a rhyme length of 3. Note that the stress on the EH sounds dont have to match.

Objective 1: Is Rhyme In the RhymingDictionary class, write a method named isRhyme that takes 2 Strings representing two words (Strings) and returns a Boolean indicating whether or not the two words rhyme (ie. Return true if the words rhyme, false otherwise). If either word is not in the dictionary, return false. Input words may contain lowercase letters. In the tests package, complete the test suite named TestIsRhyme to test this method.

Objective 2: Rhyme Length In the RhymingDictionary class, write a method named rhymeLength that takes 2 Strings representing two words (Strings) and returns the rhyming length of the two words. If the words do not rhyme, or at least one is not in the dictionary, return 0. In the tests package, write a test suite named TestRhymeLength to test this method.

Objective 3: All Rhymes In the RhymingDictionary class, write a method named allRhymes that takes 1 String representing a word (Strings) and returns all words in the dictionary that rhyme with the given word in a List of Strings, excluding the input word itself. If the input word is not in the dictionary, return an empty List. In the tests package, write a test suite named TestAllRhymes to test this method. Since the order of the returned words is not defined, you must take care in your testing to make sure that if all the correct words are returned the test will pass regardless of their order in the list. Note: Reading files is slow. If your program reads cmudict-0.7b ~122,000 times (the number of words in the dictionary) when allRhymes is called it will take a very long time to run (equivalent to reading about half a TeraByte). You should implement allRhymes in a way that limits the number of times the file is read, ideally only reading it once during object creation and never during method calls.

Primary Objective: Best Rhyme In the RhymingDictionary class, write a method named bestRhyme that takes 1 String representing a word (Strings) and returns a string representing a word that has maximum rhyme length with the input word. If multiple words maximize the rhyme length, any of them can be returned (ie. Ties are broken arbitrarily). If the input word is not in the dictionary, or doesnt rhyme with any other word, return an empty string. You should use the methods youve written in the other 3 objectives to complete this primary objective. You should write tests for this objective, though you will not receive feedback regarding your tests for the primary objective. If you ask questions during office hours and you do not have tests, the TAs are instructed to not answer your questions unless they are about testing.

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