【问题标题】:what is missing parameter in the below mentioned program?下面提到的程序中缺少什么参数?
【发布时间】:2020-01-22 04:11:06
【问题描述】:

对于下面提到的 python 程序,它显示一个错误

from nltk.stem import PorterStemmer 
ps=PorterStemmer
words = ["program", "programs", "programer", "programing", "programers"]
for w in words: 
    print(w, " : ", ps.stem(w)) 

TypeError: stem() 缺少 1 个必需的位置参数:'word'

我无法找出缺少的参数。那个参数是什么?

【问题讨论】:

    标签: python machine-learning nltk porter-stemmer


    【解决方案1】:

    你需要实例化PorterStemmer类,不要直接使用。

    这个:

    ps=PorterStemmer

    需要变成这样:

    ps = PorterStemmer()

    更多关于此事here


    未来的忠告

    在发布到 stackoverflow 之前,您必须尽可能多地进行研究。您可能已经找到了这个问题的答案,因为这是一个简单的问题,如果您将错误(完全正确)并粘贴到 Google 上。

    您会找到this answer 以及this answerthis one 等等。而你将获得的不仅仅是得到答案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-31
      • 1970-01-01
      • 1970-01-01
      • 2019-11-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多