Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java please. Relevant topic: Dictionaries. The purpose of this assignment is to gain familiarity with dictionaries. A homophone is one of two or more

In java please.
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Relevant topic: Dictionaries. The purpose of this assignment is to gain familiarity with dictionaries. A homophone is one of two or more words that are pronounced alike but are different in meaning or spelling; for example, the words "two", "too", and "to". Write a Java program that uses one of the implementations of the dictionary interface that we have discussed to find the largest set of words that are homophones. Use only UALDictionary or OALDictionary, and do not use data structures that we have not covered so far in the courie (for example hash maps or sorting algorithms other than insertion sort or selection sort). The file "emudict.0.7a.txt" on Vocareum contains a promunciation dictionary downloaded from http://www + speech. cs. cmu. edu/cgi-bin/cmudict The page also contains a detailed description of the pronunciation dictionary. The file consists of lines of the form. ABUNDANT AHO B AH1 N D AHO N T The first string is the word, which is followed by one or more phonemes (or phones) that describe the pronunciation of the word. There are 39 phonemes oceurring in North American English that are used in the dictionary. The collection of 39 symbols is known as the Arpabet, for the Advanced Research Projects Agency (ARPA), which developed it in the 1970 's in connection with research on speech understanding. The starter code on Vocareum contains several files you can use. UALDictionary.java is a class that implements the dictionary interface using an unordered array list. OALDictionary.java is a class that implements the dietionary interface using an ordered array list. The array list stores (key, value) pairs as described in the class KVpair.java. Pronunciation.java is a class that stores and manages access to a (word, phonemes) pair. There is also a program Starter.java that shows how you can read in the cmu dictionary (skipping comments and so on). Call your program MaxHomophones. The input is a single positive integer n. If the largest set of homophones in the first n-lines of the pronunciation dictionary is of sive k, then your program should print out k on the fist line, followed by k homophones, each on a new line. If there is more than one callection of k homophones, your program should print out each group, separated by a blank line. The output should be all upper case for consistency with the pronunciation dictionary. For example, if the input is 1000 then the correct output is 5 ABBE File: work/Starte File: workeronunciation java 21 /ov Containen class for a key-value pair / class KVpairkKey, E> \{ private Key k : private E e; A. Constructors il KVpair() \{ k= nu11; e= nuli; 3 Kvpair (Key kval, E eval) \{ k = kval; e= eval; I* Data memben access functions % public Key key () \{ 3) return k; public E value() \& return e; import java.util. Collections; class UALDictionary ( private static final int defaultsize =10; private ArraylisteKVpaircKey, E>> list; If Constructors UALDictionary ( ) \{ ) this(defaultsize); UALDictionary (int sz) \{ 3 list - new ArraylistcKVpairckey, E> (sz); public void clear ()\{ ) list.clear ( ) /* Insert an element: append to 1i st % public void insert (Key k, E e) i KVpairakey, Es temp i- nes kVpairkey, E) (k,e); Peo Remove element wi th public E remove (Key k) ( E temp - find (k) if if ( temp in nulf) (temp is nuif) ) return tempi fu* Remove any element is public E removeAny() t ) return list. remove (list.size ()1)-value () ; *ind k using sequential search : greturn Record with key value k. public E find (key k ) \{ for (kVpairckey, Es t; list) if (k.compare to (t,key(j))=a) return t.value(): 3. return null; /tk=does not appear in dictlonary public IterablecEs findAll (Key k ) 1 Arraylist); for (KVvairekey, Es t: 1ist) if (k-compareTo (t,key())= e al.add (t,value()): class OALDictionary implenents Dictionary \{ private static final int defaultsize =10; // Constructors OALDictionary() \{ this(defaultsize); 3 OALDictionary (int sz) f ) public void clear() \{ list.clear(); y I* Insert an element: append to list % public void insert(Key k, E e) \{ KVpaircKey, E> temp = new KVpaircKey,E>(k,e); int i=; while ((i^)) 1 ist.add (i,temp); 3 I* Remove element with key k, return element *) public E remove(Key k) \{ E temp = find (k) if (temp 1= nuli) list. remove(new KVpairKey, E> (k, temp)); 3 return temp; I* Remove any element public E removeAny() i 3 return 1 ist, remove(1ist. size ()1)value(); - Find k using sequential search * greturn Recora with key value k public E sfind(Key k ) \{ for (KVpair(t.key())=) return t, value( ) 3 return nu11; 1 , k " does not appear in dictionary Find k using binary search Ereturn Record with key value k File: work/OALDictionary.java 7. runaall umplementatson using inetricient sequentral search

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

In Exercise draw the given planar graph without any crossings.

Answered: 1 week ago

Question

Are these written ground rules?

Answered: 1 week ago

Question

How do members envision the ideal team?

Answered: 1 week ago

Question

Has the team been empowered to prioritize the issues?

Answered: 1 week ago