Python 使用波特词干分析器时的NLTK输入错误

Python 使用波特词干分析器时的NLTK输入错误,python,nlp,nltk,importerror,porter-stemmer,Python,Nlp,Nltk,Importerror,Porter Stemmer,我正在导入nltk,但它给出了以下错误 Traceback (most recent call last): File "/home/control/Work/Intelligence/Datasets/whats cooking/new.py", line 4, in <module> import nltk File "/usr/local/lib/python2.7/dist-packages/nltk-3.0.5-py2.7.egg/nltk/__init__

我正在导入nltk,但它给出了以下错误

Traceback (most recent call last):
  File "/home/control/Work/Intelligence/Datasets/whats cooking/new.py", line 4, in <module>
    import nltk
  File "/usr/local/lib/python2.7/dist-packages/nltk-3.0.5-py2.7.egg/nltk/__init__.py", line 137, in <module>
    from nltk.stem import *
  File "/usr/local/lib/python2.7/dist-packages/nltk-3.0.5-py2.7.egg/nltk/stem/__init__.py", line 29, in <module>
    from nltk.stem.snowball import SnowballStemmer
  File "/usr/local/lib/python2.7/dist-packages/nltk-3.0.5-py2.7.egg/nltk/stem/snowball.py", line 25, in <module>
    from nltk.stem import porter
ImportError: cannot import name porter
回溯(最近一次呼叫最后一次):
文件“/home/control/Work/Intelligence/Datasets/whats cooking/new.py”,第4行,在
导入nltk
文件“/usr/local/lib/python2.7/dist-packages/nltk-3.0.5-py2.7.egg/nltk/__init___.py”,第137行,in
从nltk.stem导入*
文件“/usr/local/lib/python2.7/dist packages/nltk-3.0.5-py2.7.egg/nltk/stem/_init__.py”,第29行,in
从nltk.stem.snowball导入SnowballStemmer
文件“/usr/local/lib/python2.7/dist packages/nltk-3.0.5-py2.7.egg/nltk/stem/snowball.py”,第25行,in
从nltk.stem导入porter
导入错误:无法导入名称

几天前,我的nltk工作正常,我没有更新或更改任何内容,我还安装了所有nltk数据。

在nltk中使用Porter stemmer的惯用用法(请参阅)是:

>>> from nltk.stem import PorterStemmer
>>> porter = PorterStemmer()
>>> sent = 'I went on wild geese chases'
>>> porter.stem(sent)
u'I went on wild geese chas'
注意:
PorterStemmer
不能很好地处理不规则复数

看看: