【发布时间】:2017-01-22 19:56:01
【问题描述】:
我没有做正确的事情——从我得到的错误的外观来看,我认为我丢失了一些数据。我为sentiment_classifier (https://pypi.python.org/pypi/sentiment_classifier/0.7) 安装了所有先决条件,它们是nltk、numpy 和sentiwordnet。这是我的代码 - 我正在尝试开始工作的文档中的一个快速示例。
from senti_classifier import senti_classifier
sentences = ['The movie was the worst movie', 'It was the worst acting by the actors']
pos_score, neg_score = senti_classifier.polarity_scores(sentences)
print pos_score, neg_score
这是我收到的错误消息
Traceback (most recent call last):
File "/home/beef/sciencefair2017/sentiment.py", line 1, in <module>
from senti_classifier import senti_classifier
File "build/bdist.linux-x86_64/egg/senti_classifier/senti_classifier.py", line 227, in <module>
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1178, in resource_stream
self, resource_name
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1454, in get_resource_stream
return io.BytesIO(self.get_resource_string(manager, resource_name))
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1457, in get_resource_string
return self._get(self._fn(self.module_path, resource_name))
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1535, in _get
return self.loader.get_data(path)
IOError: [Errno 0] Error: 'senti_classifier/data/SentiWn.p'
有什么问题,我怎样才能让它工作?任何建议,即使只是一个建议而不是一个实际的解决方案,我们都非常感谢。我已经尝试了所有软件包的各种版本,但我查看了一些文档无济于事。
【问题讨论】:
-
我认为这可能不是问题,但您能否尝试删除
by the actors到by the actors中的多余空格(“by”和“the”之间的一个空格)?跨度> -
@fedepad 刚刚编辑了它——很惊讶我自己没有注意到它!这些东西通常真的让我很烦。
-
如果可行,我会写一个答案......但我不确定这是问题所在。我正在查看库中的代码以查看它。告诉我。
-
好的,我认为这不是代码的问题。加载数据文件夹时似乎有问题,特别是 senti_classifier/data/SentiWn.p.
-
那个文件在某个地方吗?
标签: python nltk sentiment-analysis wordnet