首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于senti_classifier和NLTK的情感分析

基于senti_classifier和NLTK的情感分析
EN

Stack Overflow用户
提问于 2017-01-23 03:56:02
回答 2查看 933关注 0票数 1

我没有做正确的事情--从我得到的错误来看,我想我遗漏了一些数据。我已经安装了sentiment_classifier (https://pypi.python.org/pypi/sentiment_classifier/0.7)的所有先决条件,它们是nltk、numpy和sentiwordnet。这是我的代码--我正在尝试使用的文档中的一个快速示例。

代码语言:javascript
复制
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

下面是我收到的错误消息

代码语言:javascript
复制
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'

问题出在哪里?我怎样才能让它正常工作?任何建议,即使只是一个建议,而不是一个实际的解决方案,都是非常感谢的。我已经尝试了所有包的不同版本,并且我已经查看了一些文档,但都没有用。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-01-23 07:30:09

我弄明白了:我没有安装完整的包-我最初使用pip,但我必须像这样安装它:

代码语言:javascript
复制
git clone https://github.com/kevincobain2000/sentiment_classifier
cd sentiment_classifier
python setup.py install

现在效果很好。

票数 2
EN

Stack Overflow用户

发布于 2017-05-11 01:34:01

在:

代码语言:javascript
复制
import inspect
all_functions = inspect.getmembers(senti_classifier, inspect.isfunction)
all_functions

输出:

代码语言:javascript
复制
[]

senti_classifier模块中没有函数。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41795476

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档