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
How many hours should I charge a 4.8v 600mah battery (I need it by today please)
prohojiy [21]

The number of hours that will be needed to charge a 600mah battery will be 1.5 hours.

<h3>What is a battery?</h3>

It should be noted that an electric battery simply means a source of electric power that consist of one or more electrochemical cells that are with external connections that are important for powering electrical devices.

It should be noted that when a battery is supplying power, then the positive terminal is the cathode while the negative terminal is the anode.

In conclusion, the number of hours that will be needed to charge a 600mah battery will be 1.5 hours.

Learn more about battery on:

brainly.com/question/16896465

#SPJ1

5 0
2 years ago
Marks
Lina20 [59]

Answer:

i think C

Explanation:

if not really sorry

3 0
2 years ago
The 15-kg block A slides on the surface for which µk = 0.3. The block has a velocity v = 10 m/s when it is s = 4 m from the 10-k
sammy [17]

Answer:

s_max = 0.8394m

Explanation:

From equilibrium of block, N = W = mg

Frictional force = μ_k•N = μ_k•mg

Since μ_k = 0.3,then F = 0.3mg

To determine the velocity of Block A just before collision, let's apply the principle of work and energy;

T1 + ΣU_1-2 = T2

So, (1/2)m_a•(v_ao)² - F•s =(1/2)m_a•(v_a1)²

Plugging in the relevant values to get ;

(1/2)•(15)•(10)² - (0.3•15•9.81•4) =(1/2)(15)•(v_a1)²

750 - 176.58 = 7.5(v_a1)²

v_a1 = 8.744 m/s

Using law of conservation of momentum;

Σ(m1v1) = Σ(m2v2)

Thus,

m_a•v_a1 + m_b•v_b1 = m_a•v_a2 + m_b•v_b2

Thus;

15(8.744) + 10(0) = 15(v_a2) + 10(v_b2)

Divide through by 5;

3(8.744) + 2(0) = 3(v_a2) + 2(v_b2)

Thus,

3(v_a2) + 2(v_b2) = 26.232 - - - (eq1)

Coefficient of restitution has a formula;

e = (v_b2 - v_a2)/(v_a1 - v_b1)

From the question, e = 0.6.

Thus;

0.6 = (v_b2 - v_a2)/(8.744 - 0)

0.6 x 8.744 = (v_b2 - v_a2)

(v_b2 - v_a2) = 5.246 - - - (eq2)

Solving eq(1) and 2 simultaneously, we have;

v_b2 = 8.394 m/s

v_a2 = 3.148 m/s

Now, to find maximum compression, let's apply conservation of energy on block B;

T1 + V1 = T2 + V2

Thus,

(1/2)m_b•(v_b2)² + (1/2)k(s_1)² = (1/2)m_b•(v_b'2)² + (1/2)k(s_max)²

(1/2)10•(8.394)² + (1/2)1000(0)² = (1/2)10•(0)² + (1/2)(1000)(s_max)²

500(s_max)² = 352.29618

(s_max)² = 352.29618/500

(s_max)² = 0.7046

s_max = 0.8394m

8 0
3 years ago
What is the IMA of this pulley belt system if the diameter of the input
Stella [2.4K]

Answer:

2.8

Explanation:

The ideal mechanical advantage of the pulley IMA  = D'/D where D' = diameter of output pulley = 7 inches and D = diameter of input pulley = 2.5 inches

So, IMA = D'/D

= 7/2.5

= 2.8

So, the ideal mechanical advantage of the pulley IMA = 2.8

8 0
2 years ago
U 4. Find 2 bridges in the US and answer the following:
Zarrin [17]

Answer:

Im guessing this is for CEA for PLTW, if so look up the exact assignment number and look at online examples of the exact same assignment.

Explanation:

6 0
3 years ago
Other questions:
  • To cool a summer home without using a vapor compression refrigeration cycle, air is routed through a plastic pipe (k=0.15 W/m*K,
    15·1 answer
  • An array of electronic chips is mounted within a sealedrectangular enclosure, and colling is implemented by attaching analuminum
    5·1 answer
  • What is Differential Analysis in fluid mechanics?
    13·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
  • An organization is struggling to differentiate threats from normal traffic and access to systems. A security engineer has been a
    12·1 answer
  • 1. How does manufacturing help strengthen<br> the economy?
    15·1 answer
  • (a) Consider a germanium semiconductor at T 300 K. Calculate the thermal equilibrium electron and hole concentrations for (i) Nd
    7·1 answer
  • I don't know what is this​
    9·1 answer
  • What does it mean to say that PEER is a data-driven, consumer-centric, and comprehensive system?
    8·2 answers
  • A 75-hp motor that has an efficiency of 91.0% is worn-out and is replaced by a motor that has a high efficiency 75-hp motor that
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!