gpt4 book ai didi

python - 使用 Porter Stemmer 时出现 NLTK 导入错误

转载 作者:太空宇宙 更新时间:2023-11-03 17:23:17 25 4
gpt4 key购买 nike

我正在导入 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 数据。

最佳答案

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 不能很好地处理不规则复数

看一下:

关于python - 使用 Porter Stemmer 时出现 NLTK 导入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32899532/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com