我正在导入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
我的nltk几天前工作正常,我没有更新或改变任何东西,我也安装了所有的nltk数据。
答案 0 :(得分:0)
在NLTK中使用Porter词干分析器(见http://www.nltk.org/howto/stem.html)将是:
>>> 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
对于不规则复数形式不能很好地使用
看看: