使用senti_classifier和NLTK的情感分析 [英] Sentiment Analysis using senti_classifier and NLTK

查看:84
本文介绍了使用senti_classifier和NLTK的情感分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有做正确的事-从错误的外观来看,我得到的是我认为我丢失了一些数据.我已安装了sentiment_classifier( https://pypi.python.org/pypi/sentiment_classifier的所有先决条件/0.7 )是nltk,numpy和sentiwordnet.这是我的代码-我正在尝试工作的文档中的一个简单示例.

I'm not doing something right -- By the looks of the error i'm getting i think i'm missing some data. I have all the prerequisites intalled for sentiment_classifier (https://pypi.python.org/pypi/sentiment_classifier/0.7) which are nltk, numpy, and sentiwordnet. Here's my code - a quick example from the docs i'm trying to get working.

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'

问题是什么,如何使它正常工作?任何建议,即使只是建议而不是实际解决方案,都将受到极大的赞赏.我已经尝试过所有软件包的各种版本,并且浏览了一些文档都无济于事.

what's the issue and how can i get it working? Any advice, even if only a suggestion and not an actual solution is greatly appreciated. I've already tried various versions of all the packages and I've looked through some of the docs to no avail.

推荐答案

我知道了:我没有安装完整的软件包-我最初使用pip,但是我必须像这样安装它:

I figured it out: I didn't install the full package - i originally used pip but i had to install it like so:

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

现在工作精美.

这篇关于使用senti_classifier和NLTK的情感分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆