1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ratling [72]
3 years ago
10

Software, such as a word processor, search engine, or mobile interface, typically includes plug-in support specific to a languag

e 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.
Engineering
1 answer:
bearhunter [10]3 years ago
7 0

Answer:

Check the explanation

Explanation:

class LanguageHelper:

language=set()

#Constructor

def __init__(self, words):

for w in words:

self.language.add(w)

def __contains__(self,query):

return query in self.language

def getSuggestionns(self,query):

matches = []

for string in self.language:

if string.lower().startswith(query) or query.lower().startswith(string) or query.lower() in string.lower():

matches.append(string)

return matches

lh = LanguageHelper(["how","Hi","What","Hisa"])

print('how' in lh)

print(lh.getSuggestionns('hi'))

===========================================

OUTPUT:-

==================

True

['Hisa', 'Hi']

====

You might be interested in
What are the main causes of injuries when using forklifts?
vagabundo [1.1K]

The forklift overturning is a very common way of getting injured from a forklift. Overturning the forklift means it tips over onto it's side due to the operator turning it too fast.

5 0
4 years ago
A timing light checks the ignition timing in relation to the ____ position.
kogti [31]

Answer:

The timing light is connected to the ignition circuit and used to illuminate the timing marks on the engine's crankshaft pulley or flywheel, with the engine running. The apparent position of the marks, frozen by the stroboscopic effect, indicates the current timing of the spark in relation to piston position.

Explanation:

:)

8 0
3 years ago
What do you own that might not be manufactured?
horrorfan [7]

Answer:

A pet

Explanation:

Latin time I checked animals aren't made by people? I honestly don't know if this helps but I'm technically not wrong.

8 0
3 years ago
During January, at a location in Alaska winds at -20°C can be observed, However, several meters below ground the temperature rem
maw [93]

Answer:

a) \eta_{th} = 10.910\,\%, b) Yes.

Explanation:

a) The maximum thermal efficiency is given by the Carnot's Cycle, whose formula is:

\eta_{th} =\left(1-\frac{253.15\,K}{284.15\,K}  \right) \times 100\,\%

\eta_{th} = 10.910\,\%

b) The claim of the inventor is possible since real efficiency is lower than maximum thermal efficiency.

4 0
3 years ago
Which of the following bonding is the strongest? (a) lonic bonding (b) Metallic bonding (c) Covalent bonding with some van der W
OLEGan [10]

Answer:

(a) lonic bonding

Explanation:

The Strongest chemical bond is the ionic bond ,

Because ionic bond is bound by strong electrostatic interactions ,

The ionic bond forms crystal lattice structure which are bounded by  electrostatic interactions but the covalent bond is formed by the van der waal forces .

Hence , ionic bond is stronger than covalent bond .

7 0
3 years ago
Other questions:
  • 4. Water vapor enters a turbine operating at steady state at 1000oF, 220 lbf/in2 , with a volumetric flow rate of 25 ft3/s, and
    8·1 answer
  • The total floor area of a building, including below-grade space but excluding unenclosed areas, measured from the exterior of th
    8·1 answer
  • A material has the following properties: Sut = 275 MPa and n = 0.40. Calculate its strength coefficient, K.
    14·1 answer
  • Using the celsius_to_kelvin function as a guide, create a new function, changing the name to kelvin_to_celsius, and modifying th
    5·1 answer
  • Match each context to the type of the law that is most suitable for it.
    7·1 answer
  • ANSWER FAST PLEASE!!! WILL MARK BRAINLIEST!!!!!!
    10·2 answers
  • This elementary problem begins to explore propagation delayand transmission delay, two central concepts in data networking. Cons
    6·1 answer
  • Fill in the blank to correctly complete the statement below.
    10·1 answer
  • a stem and leaf display describes two-digit integers between 20 and 80. for one one of the classes displayed, the row appears as
    6·1 answer
  • What is a beta testing ?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!