Implement a Lexicon class used to help manage a set of words belonging to a language.

Language (or Software): Python
Exercise 8.21

Implement a Lexicon class used to help manage a set of words belonging to a language. The constructorshould accept a parameter that is an open file from which the words can be read. The underlying filewill have one word per line. The constructor should read those lines and save each word into an internallist of words (akin to that on p. 280).Then implement the contains method to test whether a given word is considered to be legal,based on the following rule. If a word in the lexicon is lowercase (e.g., python) then it may be legallyspelled as either lowercase or uppercase. (For example, at the beginning of a sentence it will be uppercase.)However, a word that is uppercase in the word list (e.g. Arthur) is only legal when uppercase.(Arthur) is a name, and must be uppercase, even when in the middle of a sentence.) A sample test forthis class follows.

Exercise 8.22

Use the Lexicon class of Exercise 8.21 to create a basic spell checker class . The program which usesthis class should build a lexicon (a Lexicon object) based on an underlying le of words for a language.The it should read a document le indicated by the user. The goal is to produce a list of words from thedocument that do not appear in the lexicon. The assumption is that if a word is not in the lexicon, itis because the word is not spelled correctly. For the source document, you may presume that the wordsare delimited with whitespace (and without any puctuation).Your solution should use a class called SpellChecker. The constructor for this class will take twoparameters: a Lexicon object and an open le object (whose underlying le is the source documentwhose spelling is being checked). The main feature of the class should be a method which returns a listof words in the source document which are not in the lexicon.The test program will ask for the name of a source le, as well as for the name of a le to includethe word list.

Exercise 8.23
Add additional functionality to your spell checker from Exercise 8.22. When reporting a misspelledword, give the line number at which it occurs in the source document. Furthermore, strip away leadingand trailing punctuation from words in the source document before looking them up in the word list.For example, ‘end.’ is a legitimate word despite the period.

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.

Click Here to Make an Order Click Here to Hire a Writer