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 0.25" diameter A36 steel rivet connects two 1" wide by .25" thick 6061-T6 Al strips in a single lap shear joint. The shear str
just olya [345]

Answer:

Option B

1025 psi

Explanation:

In a single shear, the shear area is \frac {\pi d^{2}}{4}=\frac {\pi 0.25^{2}}{4}

The shear strength=0.58\sigma_y and in this case \sigma_y=36 000 psi

Shear strength=\frac {Load}{Shear area} hence making load the subject then

Load=Shear area X Shear strength

Load=\frac {\pi 0.25^{2}}{4} \times 0.58\times 36000\approx 1025 psi

3 0
3 years ago
determine the position d of the 6- kn load so that the average normal stress in each rod is the same.
Zinaida [17]

The load is placed at distance 0.4 L from the end of $$12 \mathrm{~mm}^{2} $ area.

<h3>What is meant by torque?</h3>

The force that can cause an object to rotate along an axis is measured as torque. Similar to how force accelerates an item in linear kinematics, torque accelerates an object in an angular direction. A vector quantity is torque.

Let the beam is of length L

Now the stress on both the end is the same now we can say that torque on the beam due to two forces must be zero

$N_1 * x=N_2 *(L-x)$

also, we know that stress at both ends are same

$\frac{N_1}{12}=\frac{N_2}{8}$

$2 * N_1=3 * N_2$

Now from two equations we have

$\frac{3}{2} N_2 * x=N_2 *(L-x)

solving the above equation we have

$x=\frac{2}{5} L

so the load is placed at distance 0.4 L from the end of $$12 \mathrm{~mm}^{2} $ area.

The complete question is:

47. the beam is supported by two rods ab and cd that have cross-sectional areas of $$12mm^2 and $$8mm^2, respectively. determine the position d of the 6-kn load so that the average normal stress in each rod is the same.

To learn more about torque refer to:

brainly.com/question/20691242

#SPJ4

7 0
2 years ago
A centimeter is Viooth of a meter, while a kilo-
tatuchka [14]

Answer:

b. False

Explanation:

A centimeter is a hundredth of a meter. This means 1/100 ,1 cm = 0.01 m

A kilo is 1000 grams.

The first answer is false because a hundredth isnot written well.

The second statement is false because the comparison given is of different units of measure. For distance is meters where as for weight is kilograms.

8 0
3 years ago
1. On a 2001 Honda Civic, while replacing fuel injectors, what do you coat the new O-rings with?
scoundrel [369]

Answer:

Coat new O-rings (D) with silicone oil or polyalkyleneglycol (PAG) oil, and pull them on the injectors.

3 0
3 years ago
One method that is used to grow nanowires (nanotubes with solid cores) is to initially deposit a small droplet of a liquid catal
7nadin3 [17]

Answer: maximum length of the nanowire is 510 nm

Explanation:

 

From the table of 'Thermo physical properties of selected nonmetallic solids at At T = 1500 K

Thermal conductivity of silicon carbide k = 30 W/m.K

Diameter of silicon carbide nanowire, D = 15 x 10⁻⁹ m  

lets consider the equation for the value of m

m = ( (hP/kAc)^1/2 )  = ( (4h/kD)^1/2 )  

m =  ( ((4 × 10⁵)/(30×15×10⁻⁹ ))^1/2 ) = 942809.04    

now lets find the value of h/mk    

h/mk = 10⁵ / ( 942809.04 × 30) =  0.00353

lets consider the value θ/θb by using the equation

θ/θb = (T - T∞) / (T - T∞)

θ/θb =  (3000 - 8000) / (2400 - 8000)

= 0.893

the temperature distribution at steady-state is expressed as;

θ/θb = [ cosh m(L - x) + ( h/mk) sinh m (L - x)]   / [cosh mL+  (h/mk) sinh mL]

θ/θb = [ cosh m(L - L) + ( h/mk) sinh m (L - L)]   / [cosh mL+  (h/mk) sinh mL]

θ/θb = [ 1 ]  / [cosh mL+  (h/mk) sinh mL]

so we substitute

0.893 =  [ 1 ]  / [cosh (942809.04 × L) +  (0.00353) sinh (942809.04 × L)]

L = 510 × 10⁻⁹m

L = 510 nm

therefore maximum length of the nanowire is 510 nm

4 0
3 years ago
Other questions:
  • A tank contains liquid nitrogen at -190℃ is suspended in a vacuum shell by three stainless steel rods 0.80 cm in diameter and 3
    8·1 answer
  • A venturi meter is to be installed in a 63 mm bore section of a piping system to measure the flow rate of water in it. From spac
    15·1 answer
  • Kjhwe ,kenwif ujwfeowlwfwfwfw...
    14·2 answers
  • when a metal, such as lead, is oxidied (loses electrons) to form a positive ion (cation), how does he solubility change?
    14·1 answer
  • The formula for the cross sectional area of specimen at the middle is
    5·1 answer
  • With a reservoir pressure of 1.0 MPa and temperature of 750 K, air enters a converging-diverging nozzle, in a steady fashion. Fl
    5·1 answer
  • Who is using welding symbols to to communicate the detailed information necessary for welders to complete the weld?
    6·1 answer
  • Tech A says that coolant circulates through some intake manifolds to help warm them up. Tech B says that some intake manifolds u
    13·1 answer
  • In order to be a Mechanical Engineer, you need to:
    5·2 answers
  • A 1/20 scale model of a wing is used to determine forces on the actual airplane. the 1/20 scale refers to the:_____
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!