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
Effects of adding more insulation to a cylinder increases heat transfer area. a)-True b)-False
Xelga [282]

Answer:

a)-True

Hope this helps even tho theres no school right now

3 0
3 years ago
Define what a glass transition is and what happens to a polymer because of it
lesya692 [45]

Answer:

 The glass transition occur when the given temperature gets drop below the temperature of the glass transition for the polymers. During the creases of the long range of the given motion, the polymer start changing from the state of hard into the form of brittle.

The range of the glass transition temperature are between the 0 to -150°C. The basic use of the polymer is basically depend upon the main properties of the polymer.

7 0
3 years ago
What is the Energy of moving things?<br><br> mechanical<br> sound<br> nuclear<br> Light
Elenna [48]

Answer: Kinetic energy

Explanation: If you live in a country other than UK you will probably call it something different

4 0
3 years ago
Read 2 more answers
Use the graph to determine which statement is true about the end behavior of f(x).
Airida [17]

Answer:

As the x-values go to negative infinity, the function’s values go to positive infinity.

Explanation:

if the ans choices are:

As the x-values go to negative infinity, the function’s values go to negative infinity.

As the x-values go to negative infinity, the function’s values go to positive infinity.

As the x-values go to positive infinity, the function’s values go to negative infinity.

As the x-values go to positive infinity, the function’s values go to zero.

the ans is the 2nd choice

4 0
3 years ago
Read 2 more answers
Do not answer pls thank you
astra-53 [7]

The answer is answered! Explanation:

4 0
4 years ago
Read 2 more answers
Other questions:
  • What is the name of the model/shape below?
    5·2 answers
  • Use the APWA 5600 methodology to compute the 1/25 design discharge for the following catchment. The catchment area consists of 1
    9·1 answer
  • How are scientific discoveries used in engineering design?
    12·1 answer
  • If 65 gallons of hydraulic oil weighs 350lb, what is the specific weight of the oil in lb/ft^3?
    14·1 answer
  • Why Your first project as the new web designer at Smart Design is to increase web traffic to help boost web orders. Before you b
    6·1 answer
  • A motor cycle is moving up an incline of 1 in 30 at a speed of 80 km/h,and then suddenly the engine shuts down.The tractive resi
    11·1 answer
  • Ten dollars per hour is about how much income per year
    5·2 answers
  • Many of the products that we eat and drink are advanced manufactured products. Is this statement TRUE or FALSE?
    12·1 answer
  • 2 definiciones de personas en Técnicos en ingeniería eléctrica y agregar link.<br> Por favor❗❗❗
    13·1 answer
  • According to the article, what is one reason why commercial carmakers aim to develop driverless technology?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!