Python | Computer Science homework help

Get your original paper written from scratch starting at just $10 per page with a plagiarism report and free revisions included!

4.8

rating

SiteJabber

4.9

rating

ResellerRatings

4.9

rating

Reviews.io

Hire A Writer

  

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.

Stay Anonymous
With Our Essay Writing Service

The aim of our service is to provide you with top-class essay help when you ask us to write my paper; we do not collect or share any of your personal data. We use the email you provide us to send you drafts, final papers, and the occasional promotion and discount code, but that’s it!

Order Now