Question: In this homework, you will be implementing a Lexicon class. This Lexicon class will maintain a list of words, and the user will be able
In this homework, you will be implementing a Lexicon class. This Lexicon class will maintain a list of words, and the user will be able to query the Lexicon as to whether or not a word is in the Lexicon, the user will be able to add words to the Lexicon, or to modify a word in the Lexicon.
Constructors:
Lexicon();
A constructor that allows the user to create an empty Lexicon: Lexicon(const string& fileName);
A constructor that opens the file associated with fileName, and stores all of the words in the file in the Lexicon. If the file doesnt exist, an exception should be thrown. (N.B. The ifstream constructor takes a C-style string as a parameter to open the file and not a C++ string object. To get the C-string equivalent of any given C++ string, use the member function c_str(). For example, to get the C-string equivalent of fileName, call fileName.c_str().)
Operations:
bool containsWord(const string& word); returns true if word is in the Lexicon, and false otherwise.
list
returns a list a of words that start with a particular letter, ch.
list
returns a list of words that start with prefix.
list
list
void addWord(const string& str); Adds str to the Lexicon if it is not there already. If it is there already, do nothing.
void updateWord(const string& target, const string& replacement); Changes the spelling of target to become replacement. Operators:
friend bool operator==(const Lexicon& d1, const Lexicon& d2); returns true iff d1 and d2 contain the same words, not necessarily in the same order. (N.B. be careful here. You can not just assume that you can compare the lexicons word by word, since they may not be stored in the same order.)
friend operator <<(ostream& os, const Lexicon& d);
Outputs the content of the Lexicon (in any order).
Please submit Lexicon.h, Lexicon.cpp, and useLexicon.cpp files. Also, please use comments to document your code. These homeworks will become more and more complicated, and if I cant figure out what your intuition is in solving these problems, I cant give credit.
I have provided 2 text files with the same lexicon, but I ran a program that has randomly permuted the words such that they are no longer listed in sorted order. When these files have been stored into Lexicon objects, your == function should return true.
Text file:
abaptiston abidance abilao abdicant aberrating abac abbacomes abient aam abacaxi abhors abbreviating abilla abenteric abayah abducent 're abecedarian abets ab abattises abarthrosis abear aals abates abandonedly abactor aberrantly aberr abdaria abhenrys abalienate 's abelite abietene abbotric 7th abbotships abarticular abastardize abider abilitable abduct abbeys abidi abbreviations abirritate abasedness abaised aarrgh abdominals abduction abhenries abducing abelmosk 'slight abasers aberrometer abaddon abandonments 'slife abduced abeles abdicate abasic 'd abamps abalone abhorrible abase abdomen 'twas abhorrer abdal abcess abbreviatable abdicates 'un 'strewth abiogenist abc abbacy abdominothoracic abilities abides abetter aardvarks abandoner abey abalienated 'snails abarticulation abede abbreviation abiogenetical abigails 5th abbess abacas abassi abaka abdomina abiogenetically aback abaton abbreviated abbatical abdominogenital abbreviatory abaiser abeigh abietic abetting 'slid abend abbott abdominovesical 3rd abietite abele abalienating abattised abdicator abidal abating abdest aalii abasio aberuncate abiegh abdominales abiding a abhorrers 4th abetment aardwolves aah abacisci abir abib abaft abamp abecedary 'prentice 'em aberrations abalienation abirritant abiogenetic abaissed abbreviators
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
