subject
Engineering, 22.04.2020 02:18 1qteg

Software, such as a word processor, search engine, or mobile interface, typically includes plug-in support specific to a language to aid with spelling. In this assignment, you will implement a class that provides general language support; such a class could presumably be (re)used in these broader software applications. For the purpose of spell checking, a simple language model is a set of valid words. By convention, a language specification may include both capitalized and uncapitalized words. A word that is is entirely lowercased in the language specification can be used in either capitalized or uncapitalized from (e. g., if 'dog'is in the language specification, then both 'dog' and 'Dog' are legitimate usages). However, any word that includes one or more uppercased letters in the original language reflects a form that cannot be modified (e. g., 'Missouri' is acceptable but 'missouri' is not; 'NATO' is acceptable, but neither 'Nato', 'nato', nor 'nAto' would be acceptable). The goals of the new class will be to answer the following types of queries: • Is a given string a legitimate word in the language? (based on the above conventions regarding capitalization) • Given a string, which may or may not be in the language, produce a list of suggestions that are valid words in the language and reasonably "close" to the given string in terms of spelling. (We will say more below, about the notion of distance between words.) Formally, you are to provide a file named language_tools. py that defines aLanguageHelper class with the following three methods. _init__(self, words) The words parameter can be any iterable sequence of strings that define the words in the language. For example, the parameter may be a list of strings, or a file object that has one word per line. All you should assume about this parameter is that you are able to do a loop, for w in words: to access its entries. The class is responsible for recording all words from the language into an internal data representation, and stripping any extraneous whitespace from each entry (such as newline characters that will appear in a file). For the sake of efficiency, we recommend that you store the language words in a Python set instance. (We discuss sets in a later section.) _contains_(self, query) The query parameter is a string. This method should determine whether the string is considered a legitimate word, returning True if the word is contained in the language and False otherwise. This method should adhere to the aforementioned conventions regarding capitalized and uncapitalized words. For example, dog, Dog and Missouri are contained in the English language, yet missouri and Missourri are not. The _contains_ special method is used by Python to support the in operator. It allows the standard syntax "Missouri' in language which is implicitly translated by Python to the internal call language. _contains_('Missouri') presuming that language is an instance of our LanguageHelper class. getSuggestions (self, query) Given a query string, this method should return an alphabetical list of "nearby" words in the language. Doing a good job at offering suggestions is the most difficult part of writing a good language helper. We discuss this aspect of the project in a later section. S = set() create a new set instance (which is initially an empty set). s. add(value) adds the given value to the set (value will be a string in our application). value in s returns True if the given value is currently in the set, and False otherwise.

ansver
Answers: 1

Another question on Engineering

question
Engineering, 03.07.2019 15:10
Heat is added to a piston-cylinder device filled with 2 kg of air to raise its temperature 400 c from an initial temperature of t1 27 cand pressure of pi 1 mpa. the process is isobaric process. find a)-the final pressure p2 b)-the heat transfer to the air.
Answers: 1
question
Engineering, 04.07.2019 18:10
Water at 70°f and streams enter the mixing chamber at the same mass flow rate, determine the temperature and the quality of the exiting stream. 0 psia is heated in a chamber by mixing it with saturated water vapor at 20 psia. if both streams enters the mixing chamber at the same mass flow rate, determine the temperature and the quality of the existing system.
Answers: 2
question
Engineering, 04.07.2019 18:10
Calculate the bore of a cylinder that has a stroke of 18 inches and an extension time of 6 seconds at a flow rate of 4 gal/min.
Answers: 3
question
Engineering, 04.07.2019 18:20
Find the minimum film thickness for a journal bearing with the data below. shaft diameter, d-50 mm, clearance ratio, cdratio? 0.001, shaft speed, n 2000 rpm; bearing length. i 200 mm; eccentricity ration, ? -0.55. ( note, cdratio-ca/d) the minimum film thickness is um
Answers: 2
You know the right answer?
Software, such as a word processor, search engine, or mobile interface, typically includes plug-in s...
Questions
question
Social Studies, 07.07.2019 07:30
question
Advanced Placement (AP), 07.07.2019 07:30
Questions on the website: 13722367