使用 senti_classifier 和 NLTK 进行情感分析

Sentiment Analysis using senti_classifier and NLTK

我做错了什么 -- 从我收到的错误来看,我想我遗漏了一些数据。我已经安装了 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'

有什么问题,我该如何让它工作?非常感谢任何建议,即使只是建议而不是实际解决方案。我已经尝试了所有软件包的各种版本,并且我查看了一些文档无济于事。

我想通了:我没有安装完整的软件包 - 我最初使用 pip 但我不得不这样安装它:

git clone https://github.com/kevincobain2000/sentiment_classifier
cd sentiment_classifier
python setup.py install

现在效果很好。

在:

import inspect
all_functions = inspect.getmembers(senti_classifier, inspect.isfunction)
all_functions

输出:

[]

senti_classifier 模块中没有函数。