question archive Question 4) According to each method's documentation, complete the code of the TextProcessor class and its subclass TextAnalyzer

Question 4) According to each method's documentation, complete the code of the TextProcessor class and its subclass TextAnalyzer

Subject:Computer SciencePrice:3.86 Bought12

Question 4) According to each method's documentation, complete the code of the TextProcessor class and its subclass TextAnalyzer.

In [16]:

class TextProcessor: def __init__(self, text): self.text = text def setStopWords(): ''' set stop words as recieved in the parameters ''' ## CODE HERE ## def getStopWords(): ''' return stop words ''' ## CODE HERE ## def getUniqWords(self): return set(self.__text.split()) def getFilteredText(self): ''' remove filter words from the text return filtered text ''' ## CODE HERE ## class TextAnalyzer: def __init__(): ''' Construct the class ''' ## CODE HERE ## def getWordFrequency(): ''' Call the getFilteredText() method Create a dictionary of words key = word and value= frequency return the dictionary ''' ## CODE HERE ##

Verify the correctness of your code using the following steps:

 

  1. Instantiate the TextAnalyzer class by creating an object called ta as follows:

ta = TextAnalyzer("a quick brown fox " +

"a quick brown fox jumps " +

"a quick brown fox jumps over " +

"a quick brown fox jumps over the " +

"a quick brown fox jumps over the lazy " +

"a quick brown fox jumps over the lazy dog")

  1. Assign a list of stop words using the setStopWords() method: ta.setStopWords(['a', 'the'])
  2. Count the occurrences of each word using the getWordFrequency() method: ta.getWordFrequency()
  3. The output should be as follows {'quick': 6, 'brown': 6, 'fox': 6, 'jumps': 5, 'over': 4, 'lazy': 2, 'dog': 1}}

Option 1

Low Cost Option
Download this past answer in few clicks

3.86 USD

PURCHASE SOLUTION

Option 2

Custom new solution created by our subject matter experts

GET A QUOTE

rated 5 stars

Purchased 12 times

Completion Status 100%

Related Questions