Porter Stemmer algorithm

Stemming is the process of reducing a word to its word stem that affixes to suffixes and prefixes or to the roots of words known as a lemma. For example: words such as “Likes”, ”liked”, ”likely” and ”liking” will be reduced to “like” after stemming.

Read this article to understand Porter Stemmer algorithm in depth

Have a doubt or thought? Join the discussion now

This is a companion discussion topic for the original entry at http://iq.opengenus.org/porter-stemmer/
1 Like

Hi, in the porter Stemmer algorithm ,
I tried out your algorithm, it throughs error saying “NameError: name ‘isCons’ is not defined”

In the function
def isConsonant(self, word, i): # function that returns true only if the letter at i th position
# in the argument ‘word’ is a consonant.But if the letter is ‘y’ and the letter at i-1 th position
# is also a consonant, then it returns false.#Have changed isCons to self.isCons in line 82
letter = word[i]
if self.isCons(letter):
if letter == ‘y’ and isCons(word[i - 1]):
return False
return True
return False

I have replaced isCons(word[i - 1]) to self.isCons(word[i-1]).
Can you please look into it and let me know.
That change helped solve the issue, please update the function

1 Like

Thanks for debugging the code and fixing it.
We have reflected your change in the article :heart:

cc Author: @Surya