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
Which of the following is not an example of heat generation? a)- Exothermic chemical reaction in a solid b)- Endothermic Chemica
Sav [38]

Answer:

b) Endothermic Chemical Reactions in a solid

Explanation:

Endothermic reactions consume energy, which will result in a cooler solid when the reaction finishes.

8 0
3 years ago
An insulated rigid tank is initially evacuated. A valve is opened, and atmospheric air at 95 kPa and 17 ºC enters the tank until
Darya [45]

Answer:

T2= 406k

Explanation:

The temperature can be defined as the measurement of the intensity of the heat present in the object. Fahrenheit, kelvin and centigrade are the common scale used for measuring Temperature.

Given:

T1=170C

To convert to Kelvin

= 17+273 =290K

T1 = 290K

Pressure (P)= 95KPa

Specific heat ratio = CP/CV= K

WhereK=1.005/0.718

K = 1.4

The final temperature can be calculated using the formula below.

T2 = CP/CV × T1

=. K × T1

T2 = 1.4 × 290

T2= 406k

5 0
3 years ago
Blocks A and B each have a mass m. Determine the largest horizontal force P which can be applied to B so that A will not move re
slava [35]

Answer:

The answer is "15 N".

Explanation:

Please find the complete question in the attached file.

In frame B:

For just slipping:

\to \frac{P}{2} \cos \theta =mg \sin \theta\\\\\to P=2 mg \tan \theta \\\\

        =2 \times 1 \times  g \times \tan 37^{\circ}\\\\ =2 \times 10 \times  \frac{3}{4}\\\\ =15 \ N

4 0
3 years ago
A rotator has a weight of 100lb with a centroidal radius of gyration of 9 in. Determine the moment of inertia about the center o
Ronch [10]

Answer:

8100 lbin²

Explanation:

Moment or inertia is expressed using the formula

I = mr²

M is the mass of the body

r is the radius of gyration

Given

W = 100lb

r = 9in

Required

Moment of inertia

I = Wr²

I = 100(9)²

I = 100×81

I = 8100lbin²

Hence the moment of inertia about the center of gravity for the rotator is

8100 lbin²

8 0
3 years ago
NEED HELP PLEASE
alexira [117]

Explanation:

i believe c dye to u having a right to Express your concern if you feel to

4 0
3 years ago
Other questions:
  • 1- Design a brute-force algorithm for solving the problem below (provide pseudocode): You have a large container with storage si
    6·1 answer
  • The volume at a section of a 2-lane highway is 1800 vph in each direction and the density is approximately 30 bpm. A slow moving
    10·1 answer
  • The accumulated value in an up-counter instruction is currently 7. What will be the accumulator value after the following series
    14·1 answer
  • The rate of energy transfer by work is called power. a)-True b)-False
    15·1 answer
  • Why does the the diffusion capacitance fall off at high frequencies?
    10·1 answer
  • Give two advantages of a four-high rolling mill opposed to a two-high rolling mill for the same output diameter.
    9·1 answer
  • dentify a semiconducting material and provide the value of its band gap) that could be used in: (a) (1 point) red LED (b) (1 poi
    10·1 answer
  • For a ceramic compound, what are the two characteristics of the component ions that determine the crystal structure?
    13·1 answer
  • 19/32 reduced to its lowest form
    7·2 answers
  • does anyone know the ff creed will give brailniest to who can tell me how to memerise it plus 100 points.
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!