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
Damage reports should contain the information needed for what?
SIZIF [17.4K]

Answer:

<h2>it's damage kindly be careful</h2>
3 0
2 years ago
For which of 'water' flow velocities at 200C can we assume that the flow is incompressible ? a.1000 km per hour b. 500 km per ho
ad-work [718]

Answer:d

Explanation:

Given

Temperature=200^{\circ}\approc 473 K

Also \gamma for air=1.4

R=287 J/kg

Flow will be In-compressible when Mach no.<0.32

Mach no.=\frac{V}{\sqrt{\gamma RT}}

(a)1000 km/h\approx 277.78 m/s

Mach no.=\frac{277.78}{\sqrt{1.4\times 287\times 473}}

Mach no.=0.63

(b)500 km/h\approx 138.89 m/s

Mach no.=\frac{138.89}{\sqrt{1.4\times 287\times 473}}

Mach no.=0.31

(c)2000 km/h\approx 555.55 m/s

Mach no.=\frac{555.55}{\sqrt{1.4\times 287\times 473}}

Mach no.=1.27

(d)200 km/h\approx 55.55 m/s

Mach no.=\frac{55.55}{\sqrt{1.4\times 287\times 473}}

Mach no.=0.127

From above results it is clear that for Flow at velocity 200 km/h ,it will be incompressible.

5 0
3 years ago
What is the relationship of waste management and bioremediation?
andriy [413]

Answer:

In the simplest terms, bioremediation is a waste management process using live organisms to neutralize or remove harmful pollutants from contaminated areas. Bioremediation is an environmental science that amplifies natural biological actions to remedy or remediate polluted groundwater and contaminated soil.

Explanation:

4 0
2 years ago
Read 2 more answers
A polyethylene rod exactly 10 inches long with a cross-sectional area of 0.04 in2 is used to suspend a weight of 358 lbs-f (poun
Nadya [2.5K]

Answer:

Final length of the rod = 13.90 in

Explanation:

Cross Sectional Area of the polythene rod, A = 0.04 in²

Original length of the polythene rod, l = 10 inches

Tensile modulus for the polymer, E = 25,000 psi

Viscosity, \eta = 1*10^{9} psi -sec

Weight = 358 lbs - f

time, t = 1 hr = 3600 sec

Stress is given by:

\sigma = \frac{Force}{Area} \\\sigma = \frac{358}{0.04} \\\sigma = 8950 psi

Based on Maxwell's equation, the strain is given by:

strain = \sigma ( \frac{1}{E} + \frac{t}{\eta} )\\Strain = 8950 ( \frac{1}{25000} + \frac{3600}{10^{9} } )\\Strain = 0.39022

Strain = Extension/(original Length)

0.39022 = Extension/10

Extension = 0.39022 * 10

Extension = 3.9022 in

Extension = Final length - Original length

3.9022 =  Final length - 10

Final length = 10 + 3.9022

Final length = 13.9022 in

Final length = 13.90 in

7 0
3 years ago
Universal Containers uses the Case object to track service tickets. They have implemented Case teams to allow multiple support r
inna [77]

Answer:

Universal Containers uses the Case object to track service tickets. They have implemented Case teams to allow multiple support representatives to manage the Cases. Which two "Filter by owner" options would the user see while creating a list view on the Case object?

Choose 2 answers

A. My Case Teams

B. Roles

C. Public Groups

D. Queue

Correct answer is option A and D

A) My case teams &

D) Queue

Explanation:

Since a case team was implemented to allow multiple support representatives manage the case, the two filter by owner options the user will see are; my case teams and queue.

Queue entails choosing a specific case queue to look at for your view. Which in this case the user will see because the case isn't handled by one person.

In my case teams, cases are filtered to look at only cases where you’re on the case team.

6 0
3 years ago
Other questions:
  • You find a publication from a research laboratory that identifies a new catalyst for ammonia synthesis. The article contains the
    6·1 answer
  • A water pump delivers 6 hp of shaft power when operating. The pressure differential between the outlet and the inlet of the pump
    9·1 answer
  • Why research and development in Maintenance Engineering?
    6·1 answer
  • Consider a voltage v = Vdc + vac where Vdc = a constant and the average value of vac = 0. Apply the integral definition of RMS t
    7·1 answer
  • The normal stress at gage H calculated in Part 1 includes four components: an axial component due to load P, σaxial, P, a bendin
    9·1 answer
  • Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print
    10·1 answer
  • How do we need to prepare for the future?
    10·1 answer
  • What does abbreviation vom stand for
    14·2 answers
  • Describe how to use cleaning tools and equipment safely and properly
    6·1 answer
  • What are the BENEFITS and RISKS of using automobiles?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!