0

I have been experimenting with nltk, and I do not understand what my mistake is.`

I tried this:

from nltk.stem import PorterStemmer

stemmer = PorterStemmer
examples = ["cars", "eating", "quickly"]

for w in examples:
    print(stemmer.stem(w))

And Python returns this:

TypeError: stem() missing 1 required positional argument: 'word'

Could anyone explain to me what I am doing wrong? Thanks in advance!

bigcpu
  • 3
  • 5

1 Answers1

0

Add () to PorterStemmer since it is a class instantiation and it should work:

from nltk.stem import PorterStemmer

stemmer = PorterStemmer()
examples = ["cars", "eating", "quickly"]

for w in examples:
    print(stemmer.stem(w))

stdout:

car
eat
quickli
Montenegrodr
  • 1,597
  • 1
  • 16
  • 30