Home / Expert Answers / Computer Science / nbsp-python-suffix-stripping-stemmer-stemming-is-the-process-of-extracting-the-base-word-from-a-w-pa276

(Solved):   Python: Suffix-stripping Stemmer Stemming is the process of extracting the base word from a w ...



 

Python: Suffix-stripping Stemmer
Stemming is the process of extracting the base word from a word. For instal
the base for "worked" is "work".
Use the following algorithm to stem a word:
1. If the word ends in 'ed', 'ly', or 'ing', remove the suffix.
2. If the resulting word is longer than 8 letters, keep the first 8 letters.

Stemming is the process of extracting the base word from a word. For instail the base for worked is work.
Use the followi

11 #
12 # Complete the stemmer function below.
13 #
14 # The function is expected to return a STRING.
15 # The function acc

Stemming is the process of extracting the base word from a word. For instail the base for "worked" is "work". Use the following algorithm to stem a word: 1. If the word ends in 'ed'. 'ly', or 'ing', remove the suffix. 2. If the resulting word is longer than 8 letters, keep the first 8 letters. Implement a function that takes a string of space-separated words and returns its stemmed counterpart. Example text = 'an extremely dangerous dog is barking' 'an' does not end in one of the suffixes and is less than 8 letters. 'extremely' is 'extreme' after removing the suffix. 'extreme' is less than 8 letters. 'dangerous' is 9 letters long, so reduce it to 8 letters: 'dangerou'. 'dog' and 'is' are unchanged. 'barking' is 'bark' after removing the suffix, and is less than 8 letters. Return 'an extreme dangerou dog is bark'. Function Description Complete the function stemmer in the editor below. stemmer has the following parameter(s): string text: the input text Returns string: the input text with each of the words replaced by its stem Constraints - Every character in text is either an English lowercase letter or a space character. - text starts and ends with a letter. No two consecutive characters are spaces. - text contains at most 100 words. - No word is longer than 18 letters. - Input Format Format for Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains a string, text. 11 # 12 # Complete the 'stemmer' function below. 13 # 14 # The function is expected to return a STRING. 15 # The function accepts STRING text as parameter. \( 16 \# \) 17 18 def stemmer (text): 19 # Write your code here


We have an Answer from Expert

View Expert Answer

Expert Answer


def stemmer (text): l=[] # first we take empty list lis=text.split() # convert given text into list by split method for i in lis: if i.endswith('ly'): # check th
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe