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
Define Viscosity. What are the main differences between viscous and inviscid flows?
Evgesh-ka [11]

1. Define <em>Viscosity</em>

In physics, <em>Viscosity</em> refers to the level of resistance of a fluid to flow due to internal friction, in other words, viscosity is the result of the magnitude of internal friction in a fluid, as measured by the force per unit area resisting uniform flow. For example, the honey is a fluid with high viscosity while the water has low viscosity.

What are the main differences between viscous and inviscid flows?

Viscous flows are flows that has a thick, sticky consistency between solid and liquid, contain and conduct heat, does not have a rest frame mass density and whose motion at a fixed point always remains constant. Inviscid flows, on the other hand, are flows characterized for having zero viscosity (it does not have a thick, sticky consistency), for not containing or conducting heat, for the lack of steady flow and for having a rest frame mass density

Furthermore, viscous flows are much more common than inviscid flows, while this latter is often considered an idealized model since helium is the only fluid that can become inviscid.

5 0
3 years ago
Define waves as it applies to electromagnetic fields
julsineya [31]

Waves in the electric and magnetic fields are known as electromagnetic waves. You must first understand what a field is, which is just a technique of giving each square inch of space a numerical value. You may see that as a temperature field, for instance, when you look at the weather predictions and they mention the temperature in several locations. Every location on Earth has a unique temperature that can be quantified. Everywhere on Earth has its own wind velocity, which is another form of field. This field differs somewhat from the temperature field in that the wind velocity has both a direction and a magnitude, whereas the temperature just has a magnitude (how hot it is). A vector is a quantity that has both magnitude and direction, hence a field that contains vectors at every location is referred to as a vector field. Vector fields include the magnetic and electric fields. We may examine what would happen if we placed a charged particle at any given position in space. If the charged particle were to accelerate, we would state that the electric field there is the direction in which the particle is moving. In general, positively charged particles will move in the electric field's direction, whereas negatively charged particles will move in the opposite way. Because it is a vector field, the magnetic field exhibits comparable behavior. We discovered in the 19th century that the same interaction, electromagnetism, really produces both electric and magnetic fields. Like an electromagnet, a changing electric field will produce a magnetic field, and a changing magnetic field will induce an electric field (like in a generator). If your system is configured properly, you may have an electric field that fluctuates, which in turn produces a magnetic field, which in turn induces another electric field, which in turn generates another magnetic field, and so on indefinitely. At the speed of light, this oscillation between a strong magnetic field and strong electric field spreads out indefinitely. In reality, light is an electromagnetic wave—an oscillation in the electromagnetic fields. An electric or magnetic field may exist without a medium since they exist in a vacuum, which implies that waves in these fields don't require a medium like sound to flow through.

5 0
2 years ago
A rectangular open box, 25 ft by 10 ft in plan and 12 ft deep weighs 40 tons. Sufficient amount of stones is placed in the box a
dimulka [17.4K]

Answer:

44.95 tonnes

Explanation:

According to principle of buoyancy the object will just sink when it's weight is more than the weight of the liquid it displaces

It is given that empty weight of box = 40 tons

Let the mass of the stones to be placed be = M tonnes

Thus the combined mass of box and stones = (40+M) tonnes..........(i)

Since the box will displace water equal to it's volume V we have volume of box = 25ft*10ft*12ft= 3000ft^{3}

Volume= 84.95m^{3}

Since 1ft^{3} =0.028m^{3}

Now the weight of water displaced = Weight =\rho \times Volumewhererho is density of water = 1000kg/m^{3}

Thus weight of liquid displaced = \frac{84.95X1000}{1000}tonnes=84.95 tonnes..................(ii)

Equating i and ii we get

40 + M = 84.95

thus Mass of stones = 44.95 tonnes

3 0
3 years ago
At a point on the free surface of a stressed body, the normal stresses are 20 ksi (T) on a vertical plane and 30 ksi (C) on a ho
victus00 [196]

Answer:

The principal stresses are σp1 = 27 ksi, σp2 = -37 ksi and the shear stress is zero

Explanation:

The expression for the maximum shear stress is given:

\tau _{M} =\sqrt{(\frac{\sigma _{x}^{2}-\sigma _{y}^{2}  }{2})^{2}+\tau _{xy}^{2}    }

Where

σx = stress in vertical plane = 20 ksi

σy = stress in horizontal plane = -30 ksi

τM = 32 ksi

Replacing:

32=\sqrt{(\frac{20-(-30)}{2} )^{2} +\tau _{xy}^{2}  }

Solving for τxy:

τxy = ±19.98 ksi

The principal stress is:

\sigma _{x}+\sigma _{y} =\sigma _{p1}+\sigma _{p2}

Where

σp1 = 20 ksi

σp2 = -30 ksi

\sigma _{p1}  +\sigma _{p2}=-10 ksi (equation 1)

\tau _{M} =\frac{\sigma _{p1}-\sigma _{p2}}{2} \\\sigma _{p1}-\sigma _{p2}=2\tau _{M}\\\sigma _{p1}-\sigma _{p2}=32*2=64ksi equation 2

Solving both equations:

σp1 = 27 ksi

σp2 = -37 ksi

The shear stress on the vertical plane is zero

4 0
3 years ago
Scenario* The organization is a regional XYZ Credit Union/Bank that has multiple branches and locations throughout the region.*
fiasKO [112]

Answer:

1) For preparation of plan :

It is to gather the team and creating the timeline. Gathering the inputs for the plan and confirming the mission and vision then launching the strategy.

2) A mission would describe about the company and the specification of the company

A vision is the long term or future state of the organization to achieve in a time frame.

Both would include the OAS statements and strategic shifts.

3) The OAS and strategic shift would help to create a balanced score card that would help for data gathering and analysis

This would include the financial, customers goal, Process goals, people's goals etc.

4) To create and develop the plan's framework:

To set the objective for high level organizational goals

To measure the and accomplish the objectives

To take initiatives to achieve the objectives

Explanation:

8 0
3 years ago
Other questions:
  • One-dimensional, steady-state conduction with uniform internal energy generation occurs in a plane wall with a thickness of 50 m
    14·1 answer
  • An AC sine wave has an effective value of 100V what’s the peak value of the waveform
    6·1 answer
  • Unwanted resistance is being discussed.
    12·1 answer
  • Acredit report summarizes a person's Acredit score is measure of a person's as a borrower a factor that contributes to a person'
    15·1 answer
  • The water behind Hoover Dam in Nevada is 221 m higher than the Colorado River below it. At what rate must water pass through the
    6·1 answer
  • Traffic at a roundabout moves
    8·1 answer
  • What are the benefits of using a multi view sketch to communicate a design
    14·1 answer
  • Determine the average power, complex power and power factor (including whether it is leading or lagging) for a load circuit whos
    9·2 answers
  • 2.44mW of incident 520 nm light is directed through a1 cm sample cuvette and 0.68 mW of Plight exits the sample what is the abso
    9·1 answer
  • -Electronic control modules can easily evaluate the voltage and current levels of circuits to which they are connected and deter
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!