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, 04.07.2019 18:10
Abrake has a normal braking torque of 2.8 kip in and heat-dissipating cast-iron surfaces whose mass is 40 lbm. suppose a load is brought to rest in 8.0 s from an initial angular speed of 1600 rev/min using the normal braking torque; estimate the temperature rise of the heat dissipating surfaces.
Answers: 3
question
Engineering, 04.07.2019 18:10
Hydraulic fluid with a sg. of 0.78 is flowing through a 1.5 in. i.d. pipe at 58 gal/min. the fluid has an absolute viscosity of 11.8 x 105 lbf-sec/ft2. is the flow laminar, turbulent or within the critical range? give both a numerical reynolds number and a term answer.
Answers: 3
question
Engineering, 04.07.2019 18:20
Describe one experiment in which the glass transition temperature and melting temperature of a totally amorphous thermoplastic material can be determined. show the relevant experimental results in a diagram which should be properly annotated with the two temperatures clearly marked. what is likely to happen to the curve in the diagram if the amorphous polymer is replaced by a thermosetting type?
Answers: 2
question
Engineering, 04.07.2019 18:20
A2-m rigid tank initially contains saturated water vapor at 100 kpa. the tank is connected to a supply line through a valve. steam is flowing in the supply line at 600 kpa and 300 c. the valve is opened, and steam is allowed to enter the tank until the pressure in the tank reaches the line pressure, at which point the valve is closed. a thermometer placed in the tank indicates that the temperature at the final state is 200°c. determine (a) the mass of steam that has entered the tank (b) the amount of heat transfer.
Answers: 3
You know the right answer?
Software, such as a word processor, search engine, or mobile interface, typically includes plug-in s...
Questions
question
History, 02.11.2020 19:00
question
History, 02.11.2020 19:00
Questions on the website: 13722360