Reference no: EM132198934
Write a French/English dictionary lookup program. Read a list of pairs of English and French words from a file specified by the user.
English/French words should be exact matches (don't try to find partial matches).
Use the supplied EnglishFrenchDictionary.java class as your main class. Fill in the missing code in the DictionaryTable.java class to read the input file and perform the searches.
Add code to the DictionaryTable read() method to:
read pairs of lines (English word is on the first line, and the corresponding French word is on the second line), and for each pair of lines:
create an Item object for the English word and French word to store in the byEnglish array list
create an Item object for the French word and corresponding English word to store in the byFrench array list.
After reading all the words, sort the byEnglish and byFrench array lists so we can use binary search on them.
Add code to the DictionaryTable's findFrench() method to:
Create an Item object with the specified English word and null for the French word (because we don't know it yet)
Use the Collections.binarySearch() method to search for the matching Item in the byEnglish array list
If a matching Item is found, return the item's value which is the corresponding French word (hint: use getValue()).
Add similar code to the DictionaryTable's findEndlish() method to:
Create an Item object with the specified French word and null for the English word (because we don't know it yet)
Use the Collections.binarySearch() method to search for the matching Item in the byFrench array list
If a matching Item is found, return the item's value which is the corresponding English word (hint: use getValue()).
Two files have been supplied for testing your program: shortdictionary.txt and longdictionary.txt. found here: https://drive.google.com/drive/folders/0B41Z5suN4j28Um5xTEVSeGN0V0U?usp=sharing shortdictionary.txt has just a few words in it for quick testing, and longdictionary.txt has over 500 entries for more extensive testing.
The files have the format of an English word on one line, followed by the French word on the next line:
eight
huit
Amazon
amazone
april
avril
Arctic
arctique
British
britannique
. . .
A sample run of the program:
Enter the name of the dictionary file:
shortdictionary.txt
Lookup by E)nglish word, F)rench word, Q)uit?
F
Enter French word:
huit
English word: eight
Lookup by E)nglish word, F)rench word, Q)uit?
E
Enter English word:
eight
French word: huit
Lookup by E)nglish word, F)rench word, Q)uit?