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
A train travels 650 meters in 25 seconds. What is the train's velocity?
frosja888 [35]

The train is traveling 26 meters A second .

3 0
2 years ago
A 1000-MVA, 20-kV, 60-Hz, three-phase generator is connected through a 1000-MVA, 20-kV, Dy345-kV, Y transformer to a 345-kV circ
aniked [119]

Answer:

(a) the subtransient current through the breaker in per-unit and in kA rms =   71316.39kA

(b) the rms asymmetrical fault current the breaker interrupts, assuming maximum dc offset. = 152KA

Explanation:

check the attached files for explanation

7 0
3 years ago
What is the objective of phasing out an INDUCTION MOTOR before putting the machine into commission?
enyata [817]

The main objective of phasing out an INDUCTION MOTOR is to identify the ends of the stator coils.

<h3>What is an induction motor?</h3>

An induction motor is a device based on alternate electricity (AC) which is composed of three different stator coils.

An induction motor is a device also known as an asynchronous motor due to its irregular velocity.

In conclusion, the objective of phasing out an INDUCTION MOTOR is to identify the ends of the stator coils.

Learn more on induction motors here:

brainly.com/question/15721280

#SPJ1

8 0
2 years ago
Explain what a margin of safety is in driving as well as how it can help minimize risk.
Yakvenalex [24]

Answer:

A safety margin is the space left between your vehicle and the next to provide room, time and visibility at every instant

Explanation:

A safety margin is defined as an allowance given between your vehicle and the next vehicle in front to provide enough room, visibility and time to move in a safe manner to prevent the occurrence of an accident at anytime the frontal vehicle suddenly stops or slows down

Safety margins help minimize risks in the following way

1) A common knowledge of safety margins, improves predictability among road users, thereby minimizing the risk traffic accidents caused due to late communication

2) The use of safety margins helps minimize the risk due to a change in driving conditions such as when the road becomes more slippery from being covered with fluid that is being wetted

3) Safety margin can help prevent the occurrence of an accident between vehicles due to failure of a car system, such as a punctured tire or failed breaking system

4) Safety margin helps to protect road users from the introduction of obstacles on the main roads such as ongoing road construction, broken down vehicles, road blockage by vehicles involved in an accident etc

5) Safety margin help protect road users from being involved in an accident due to the loss of driving focus of the driver of the frontal vehicle

6 0
2 years ago
Whats the difference between GeForce GTX 1060 and Geforce GTX 3060? Is there any big changes to FPS and other settings?
ZanzabumX [31]

Answer:

uhhhhh, are you kidding? a GTX 3060 is far better than a 1060 ding dong

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • Define volume flow rate Q of air flowing in a duct of area A with average velocity V
    12·1 answer
  • A banked highway is designed for traffic moving at v = 88 km/h. The radius of the curve r = 314 m. show answer No Attempt 50% Pa
    5·2 answers
  • 1. A farmer had 752 sheep and took one shot that got them all. How did he do it?
    9·1 answer
  • Selling a new vehicle pays a salesperson $1500. Selling a used vehicle pays a commission of 5% of the selling price. Write an in
    9·1 answer
  • Before accurate distance standards, a cubit was the length of whose forearm?
    5·1 answer
  • Question 3. Assign boston_under_10 and manila_under_10 to the percentage of rides that are less than 10 minutes in their respect
    14·1 answer
  • A civil engineer is analyzing the compressive strength of concrete. The compressive strength is approximately normal distributed
    7·1 answer
  • What energy type is represented in the picture?
    6·2 answers
  • If a nurse does not agree to the discipline set due to a complaint made against this nurse, after reviewing the proposed agreed
    14·1 answer
  • Precast concrete curtain wall panels: Group of answer choices are typically manufactured on site and then hoisted into place. of
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!