2017-01-22 94 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模塊中沒有的功能。