我一直在尝试nltk,但我不明白我的错误是什么。`
我尝试过:
from nltk.stem import PorterStemmer
stemmer = PorterStemmer
examples = ["cars", "eating", "quickly"]
for w in examples:
print(stemmer.stem(w))
Python返回此:
TypeError: stem() missing 1 required positional argument: 'word'
有人可以向我解释我做错了什么吗? 预先感谢!
答案 0 :(得分:0)
将()
添加到PorterStemmer
,因为它是一个类实例,它应该可以工作:
from nltk.stem import PorterStemmer
stemmer = PorterStemmer()
examples = ["cars", "eating", "quickly"]
for w in examples:
print(stemmer.stem(w))
标准输出:
car
eat
quickli