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
Determine the magnitude of force P needed to start towing the 40kg crate.Also determine the location of the resultant normal for
erastova [34]

The distance from Point A=500 mm

Explanation:

M := 40kg c := 200mm

μs := 0.3 d := 3

a := 400mm e := 4

b := 800mm

Initial guesses: N_{c} := 200 N P := 50N

Plz refer to the image below

5 0
3 years ago
Which of these material properties determines how much heat you must supply to an object to raise it by a given temperature diff
Finger [1]

Answer:

specific heat

Explanation:

7 0
3 years ago
Which of the following is true regarding screw gauges and shank?
agasfer [191]
correct me if i’m wrong i’m pretty sure it’s B i’ve had the same question
6 0
3 years ago
Stone has been used as a building material since ancient times because of its compressive strength, which is the __________.
Doss [256]

Complete Question:

Stone has been used as a building material since ancient times because of its compressive strength, which is the?

Group of answer choices

A. ability to support pressure without breaking.

B. ability to press down and become solidly fixed in the ground.

C. relative weight of a block of stone to its size.

D. force a block exerts on the blocks around it.

Answer:

A. ability to support pressure without breaking.

Explanation:

Stone has been used as a building material since ancient times because of its compressive strength, which is the ability to support pressure without breaking.

Compressive strength can be defined as the ability of a structural element or particular material to withstand an applied, which is aimed at reducing the size of the structural element.

Simply stated, it is the ability of a structural element or material to withstand an applied load without deflections, fracture or having any crack.

In this context, a stone possesses the ability to resist or withstand compression loads.

Some examples of other materials or structural elements having good compressive strength are steel, bones, concrete etc. The standard unit of measurement of the compressive strength of a material is Mega Pascal (MPa) or pound-force per square inch (psi) in the United States of America.

7 0
4 years ago
Carbon dioxide (CO2) is used in industrial and research application, and is sometimes stored at very high pressure in rigid meta
12345 [234]

Answer:

a)m =  247.43 kg

b) m = 123.71 kg

Explanation:

a)

Given data:

volume  =0.8 m^3

P =  18,000 kPa

T =35 degree C = 308 K

By ideal gas equation we have following relation

PV = mRT

where R is gas constant

R = \frac{8.314}{44} = 0.18895 kJ/ kg K

m =\frac{PV}{RT}

m = \frac{18000\times 0.8}{0.18895 \times 308}

m = 247.43 kg

b)

when pressure = 9000 kPa

from ideal gas equation

PV = mRT

where R is gas constant

R = \frac{8.314}{44} = 0.18895 kJ/ kg K

m =\frac{PV}{RT}

m = \frac{9000\times 0.8}{0.18895 \times 308}

m = 123.71 kg

3 0
3 years ago
Other questions:
  • Write a MATLAB statement that results in the input request shown in bold. The​ >> shows where your statement is​ typed, an
    7·1 answer
  • Describe with an example how corroded structures can lead to environment pollution? ​
    13·1 answer
  • A _____ satellite system employs many satellites that are spaced so that, from any point on the Earth at any time, at least one
    10·1 answer
  • Consider a room with dimensions as in the sketch. Assuming all emissivities of surfaces are equal to 0.9, calculate the radiativ
    14·1 answer
  • A classroom that normally contains 40 people is to be air-conditioned with window air-conditioning units of 5 kW cooling capacit
    6·1 answer
  • The Canadair CL-215T amphibious aircraft is specially designed to fight fires. It is the only production aircraft that can scoop
    7·1 answer
  • What is the average speed of a car that travels 80km in 1.5 hours
    12·2 answers
  • Two loads connected in parallel draw a total of 2.4 kW at 0.8 pf lagging from a 120-V rms, 60-Hz line. One load absorbs 1.5 kW a
    5·1 answer
  • Global climate and weather patterns are driven by differences in the amount of heat energy in different areas of the earth. Whic
    9·1 answer
  • The variation of the pressure of a fluid with density at constant temperature is known as the _____.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!