Reference no: EM131963712
Assignment: Linked Lists
In this assignment, you will be reading in words from a pronunciation dictionary to figure out which words rhyme with each other.
To do this, you will be implementing MyLinkedList and MySortedLinkedList. Besides the lectures in class, you can read much more about the code details of how linked lists work in the book on pages 249-268.
You'll be implementing the following:
? A linked list in MyLinkedList that implements interface . You'll be using in two different ways, to store a list of and to store a list of within each object. More on this below.
? Code in the main method of that takes lines that have been read from a rhyming dictionary and stores them in the lists.
? A subclass of MyLinkedList called MySortedLinkedList , that has a method for adding items into the list in sorted order.
? Code in the main method of RhymingDict that takes pairs of words specified on the command line and outputs whether they rhyme or not.
A LinkedList is useful for storing information when you don't know how many items you need to store. In this lab, we will be iterating through a rhyming dictionary and storing words together according to their rhyming group, which is the most heavily emphasized part of their pronunciation.
In the directory of starter code for the assignment, you'll see a subdirectory called cmudict . Inside is a file called cmudict- short .dict. Opening this, you'll see lines like:
The letters after the words represent the phonemes (units of sound) you speak when you pronounce the word. The phonemes that have numbers after them (0, 1 or 2) are the emphasized phonemes, with phonemes marked with 2 having the most emphasis (say the words out loud to yourself to try this out). Two words rhyme if the share the same subset of phonemes after the most emphasized phoneme. For example:
ListInterface
MyLinkedList
RhymeGroupWords
Strings
RhymeGroupWords
RhymingDict
dignitary D IH1 G N AH0 T EH2 R IY0
necessitate N AH0 S EH1 S AH0 T EY2 T
undue AH0 N D UW1
moderated M AA1 D ER0 EY2 T IH0 D
moderated M AA1 D ER0 EY2 T IH0 D
anticipated AE0 N T IH1 S AH0 P EY2 T IH0 D
both rhyme, and they both share EY2 T IH0 D starting with the most emphasized phoneme. The EY2 T IH0 D is called the rhyming group for these two words. You'll be storing rhyming groups in a linked list of RhymeGroupWords , a class you've been provided in the starter code. Each object stores a string with the rhyme group and a list of words that share the rhyme group (a variable of type ). So you'll be using linked lists in two different ways: to store a list of RhymeGroupWords , and, within each RhymeGroupWords object, to store a list of words.
RhymingDict
The file RhymingDict.java is provided for you. It already has the following:
RhymeGroupWords
getRhymeGroup(String line)
? A method from the dictionary. For example IH0 D" ) returns, which returns the rhyme group for a line, which returns the word for a line from the dictionary.
ListInterface
getRhymeGroup( "moderated M AA1 D ER0 EY2 T
? A method For example,
"EY2 T IH0 D"
getWord(String line)
getWord( "moderated M AA1 D ER0 EY2 T IH0 D" )
returns, which returns a S tring[] of all the lines from the
1. Use your implementation of MyLinkedList to create a linked list of RhymeGroupWords , one for each unique rhyme group you encounter (there are 8 unique rhyme groups in cmudict-short.dict ). Within each RhymeGroupWords you'll store a MySortedLinkedList of words that share that rhyme group.
2. Iterate through pairs of arguments to RhymingDict and use your linked list to determine if the pair of words rhyme. For example, with the command:
java RhymingDict crumbling mumbling collections abbreviated vegetate mutate
the output would be:
In the case of the last pair of words, and , since the word doesn't appear in cmudict-short.dict , it reports that and ignores "vegetate" . If an odd number of words is passed on the command line, it ignores the last word (since it's not part of a pair).
Do not use built-in Java data structures (like ArrayList or LinkedList) in this file
"moderated"
pronunciation dictionary.
loadDictionary()
? A method
The tasks you have to do is marked with the comment TODO in the main method of
EY2 T IH0 D
RhymingDict . These tasks are:
crumbling and mumbling rhyme
collections and abbreviated don't rhyme
mutate is not in the dictionary
"vegetate"
"mutate"
"mutate".
Attachment:- Assignment-Rhyming-Linked-List.rar