Reputation: 21
from nltk.stem import PorterStemmer
english_stemmer = PorterStemmer()
class StemmedTfidfVectorizer(TfidfVectorizer):
def build_analyzer(self):
analyzer = super(TfidfVectorizer, self).build_analyzer()
return lambda doc: english_stemmer.stemWords(analyzer(doc))
I am new to python and I am having a problem when building my code. When I run the above code an error gets as given below:
return lambda doc: english_stemmer.stemWords(analyzer(doc)) AttributeError: 'PorterStemmer' object has no attribute 'stemWords'
Upvotes: 0
Views: 1791
Reputation: 1723
This is happening because there is no method 'stemWords' in PorterStemmer nltk implementation.
Here is a small example :
from nltk.stem import PorterStemmer
stemmer = PorterStemmer()
print(stemmer.stem('Running'))
run
You can read more here: http://www.nltk.org/howto/stem.html
Upvotes: 1