Sentiment Analysis using senti_classifier and NLTK

时间秒杀一切 提交于 2019-12-02 12:59:11

问题


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

and here's the error message i'm getting

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.


回答1:


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

works beautifully now.




回答2:


In:

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

Out:

[]

No functions in senti_classifier module.



来源:https://stackoverflow.com/questions/41795476/sentiment-analysis-using-senti-classifier-and-nltk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!