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 4-L pressure cooker has an operating pressure of 175 kPa. Initially, one-half of the volume is filled with liquid and the othe
vodomira [7]

Answer:

the highest rate of heat transfer allowed is 0.9306 kW

Explanation:

Given the data in the question;

Volume = 4L = 0.004 m³

V_f = V_g = 0.002 m³

Using Table ( saturated water - pressure table);

at pressure p = 175 kPa;

v_f = 0.001057 m³/kg

v_g = 1.0037 m³/kg

u_f = 486.82 kJ/kg

u_g 2524.5 kJ/kg

h_g = 2700.2 kJ/kg

So the initial mass of the water;

m₁ = V_f/v_f + V_g/v_g

we substitute

m₁ = 0.002/0.001057  + 0.002/1.0037

m₁ = 1.89414 kg

Now, the final mass will be;

m₂ = V/v_g

m₂ = 0.004 / 1.0037

m₂ = 0.003985 kg

Now, mass leaving the pressure cooker is;

m_{out = m₁ - m₂

m_{out = 1.89414  - 0.003985

m_{out = 1.890155 kg

so, Initial internal energy will be;

U₁ = m_fu_f + m_gu_g

U₁ = (V_f/v_f)u_f  + (V_g/v_g)u_g

we substitute

U₁ = (0.002/0.001057)(486.82)  + (0.002/1.0037)(2524.5)

U₁ = 921.135288 + 5.030387

U₁ = 926.165675 kJ

Now, using Energy balance;

E_{in -  E_{out = ΔE_{sys

QΔt - m_{outh_{out = m₂u₂ - U₁

QΔt - m_{outh_g = m₂u_g - U₁

given that time = 75 min = 75 × 60s = 4500 sec

so we substitute

Q(4500) - ( 1.890155 × 2700.2 ) = ( 0.003985 × 2524.5 ) - 926.165675

Q(4500) - 5103.7965 = 10.06013 - 926.165675

Q(4500) = 10.06013 - 926.165675 + 5103.7965

Q(4500) = 4187.690955

Q = 4187.690955 / 4500

Q = 0.9306 kW

Therefore, the highest rate of heat transfer allowed is 0.9306 kW

5 0
3 years ago
Identify an object in your house that contains a physical system and list three questions you could use to define the system
jonny [76]

Answer:

ALL CAREFULLY ANSWERED CORRECTLY

Explanation:

1) A loaf of Bread PHYSICAL SYSTEM

✓ How can the environment affect the edibility of the bread

✓ What are the constituents that makes up the bread

✓ What process is involved in these constituents mixing to form the loaf.

2) The law of thermodynamics makes us to understand that when heat/energy passes through a system, the systems internal energy changes with respect to the conservation of energy law. That is energy lost = energy gained. Typically, ice would melt in a cup of hot tea because of the thermal energy in the molecules of the hot tea. When you heat a material, you are adding thermal kinetic energy to its molecules and usually raising its temperature. The temperature of the ice raises due to the kinetic energy added to it and it melts to water.

3) The theory of systems view the world as a complex system of interconnected parts. If we consider the society; (financial systems, political systems, etc) we will agree that they individually have their own components and it's the summation of this components that makes the system, this implies that system thinking could be applicable in this kinda of systems as long as they are made up of components.

4) Technology has boosted every sector of our lives and it has the capacity to do more. Restricting it's importance to entertainment alone would be an underusing of its potentials. Engineering students infact should not need any drive to be encouraged about maximizing all it can do in shaping our world.

5) ~ Nature shows its splendid soul

~Never ceases to leave us in amazement

~And we are in love

4 0
3 years ago
Vocabulary review for shop
kaheart [24]
Hazard is a possible source of danger
5 0
3 years ago
Consider a junction that connects three pipes A, B and C. What can we say about the mass flow rates in each pipe for steady flow
Elis [28]

Answer:

The statement regarding the mass rate of flow is mathematically represented as follows \Rightarrow \rho \times Q_{3}=\rho \times Q_{1}+\rho \times Q_{2}

Explanation:

A junction of 3 pipes with indicated mass rates of flow is indicated in the attached figure

As a basic sense of intuition we know that the mass of the water that is in the pipe junction at any instant of time is conserved as the junction does not accumulate any mass.

The above statement can be mathematically written as

Mass_{Junction}=Constant\\\\\Rightarrow Mass_{in}=Mass_{out}

this is known as equation of conservation of mass / Equation of continuity.

Now we know that in a time 't' the volume that enter's the Junction 'O' is

1) From pipe 1 = V_{1}=Q_{1}\times t

1) From pipe 2 = V_{2}=Q_{2}\times t

Mass leaving the junction 'O' in the same time equals

From pipe 3 = V_{3}=Q_{3}\times t

From the basic relation of density, volume and mass we have

\rho =\frac{mass}{Volume}

Using the above relations in our basic equation of continuity we obtain

\rho \times V_{3}=\rho \times V_{1}+\rho \times V_{2}\\\\Q_{3}\times t=Q_{1}\times t+Q_{2}\times t\\\\\Rightarrow Q_{3}=Q_{1}+Q_{2}

Thus the mass flow rate equation becomes \Rightarrow \rho \times Q_{3}=\rho \times Q_{1}+\rho \times Q_{2}

6 0
4 years ago
When you are in charge of running a meeting, "winging it" with minimal planning is considered:
amm1812

Answer:

The correct option is;

B) Counterproductive

Explanation:

An effective requires adequate preparations, with agenda of the meeting circulated among participants. The items to be discussed should be known before hand by the participants all of whom will have had adequate background information and relevant consultations with their constituencies  so as to be able to add effectively to the meeting.

Other attributes of an effective meeting includes;

1. Ensure, notes of the meeting are taken down personally

2. Outside discussions should be made at the parking lot

3. Important decisions or points to be made should have been communicated to other members of the meeting

4. Members to attend the meeting should be well known and list of attendees reviewed

5. Meetings should be kept to schedule

6. Ensure meeting conclusions and decisions are followed up

7. Written agenda should be available

Therefore "winging it" with minimal planning is considered counterproductive.

3 0
3 years ago
Other questions:
  • If the density of states function in the conduction band of a particular semiconductor is a constant equal to K, derive the expr
    15·1 answer
  • Are engineers needed in today’s society ? Why or why not ? I need a short three paragraph essay !!! Please help me !!!
    13·1 answer
  • The entire system of components that produces power and transmits it to the road is called the vehicle's _____.
    13·1 answer
  • A program is seeded with 30 faults. During testing, 21 faults are detected, 15 of which are seeded faults and 6 of which are ind
    12·1 answer
  • The outer surface of a spacecraft in space has an emissivity of 0.6 and an absorptivity of 0.2 for solar radiation. If solar rad
    12·1 answer
  • Design a 7.5-V zener regulator circuit using a 7.5-V zener specified at 10mA. The zener has an incremental resistance of rZ = 30
    15·1 answer
  • Steam enters a steady-flow adiabatic nozzle with a low inlet velocity (assume ~0 m/s) as a saturated vapor at 6 MPa and expands
    11·1 answer
  • Pls help me it’s due today
    8·1 answer
  • Pie charts should have no more than eight segments. True or False?
    12·2 answers
  • 8. What are two ways SpaceX plans to change personal travel?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!