2017-01-22 86 views
1

我没有做正确的事情 - 通过错误的外观我越来越我认为我错过了一些数据。我已经为sentiment_classifier(https://pypi.python.org/pypi/sentiment_classifier/0.7)安装了所有先决条件,它们分别是nltk,numpy和sentiwordnet。这里是我的代码 - 来自我想要工作的文档的一个简单示例。使用senti_classifier和NLTK的情绪分析

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' 

有什么问题,以及如何我可以得到它的工作?任何建议,即使只是一个建议,而不是一个实际的解决方案,不胜感激。我已经尝试过所有软件包的各种版本,并且我浏览过一些文档无济于事。现在经过精心

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

作品 - :

+0

我不认为可能是这个问题,但是你可以尝试在actor的'由演员'删除额外的空间(“by”和“the”之间的一个空格)吗? – fedepad

+0

@fedepad只是编辑它 - 惊讶我没有注意到它自己!那东西通常真的让我感到困扰。 –

+0

我会写一个答案,如果它的工作......但我不知道这是问题所在。我正在查看库中的代码以查看该代码。让我知道。 – fedepad

回答

1

我想通了我最初使用PIP但我必须安装它像这样我没有安装完整的包。

+0

你好 - 我有类似的问题。我在PowerShell中运行python setup.py安装,我有NLTK,NumPy。我已经下载'sentiment_classifier-0.5.tar.gz',解压缩并粘贴到我的目录中的文件夹,我得到以下错误:FileNotFoundError:[Errno 2]没有这样的文件或目录:'C:\\ Users \\ AC \ \ Anaconda3 \\ \\ LIB站点包\\ \\ senti_classifier数据\\ SentiWn.p”。任何想法,我做错了什么?我知道它没有找到文件,但我可以在我的目录中看到它。数据文件是空白的。假设可能与此有关,但我无法证实 – AdrianC

0

在:

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

日期:

[] 

senti_classifier模块中没有的功能。