kevincobain2000 / sentiment_classifier

Sentiment Classification using Word Sense Disambiguation
Other
172 stars 33 forks source link

Getting No module named Collections error in senti_classifier line 229 #11

Closed chaitralikulkarni closed 7 years ago

chaitralikulkarni commented 7 years ago

Hi,

If I try to import senti_classifier, I get the aforementioned error at line 229 - pickle.load(senti_pickle).

I have pulled latest code from master.

Regards, Chaitrali

kevincobain2000 commented 7 years ago

I cannot reproduce it. It works fine from master

➜  temp git clone https://github.com/kevincobain2000/sentiment_classifier
Cloning into 'sentiment_classifier'...
remote: Counting objects: 1631, done.
remote: Total 1631 (delta 0), reused 0 (delta 0), pack-reused 1631
Receiving objects: 100% (1631/1631), 24.70 MiB | 6.00 MiB/s, done.
Resolving deltas: 100% (415/415), done.
➜  temp cd sentiment_classifier
➜  sentiment_classifier git:(master) sudo python setup.py install
Password:
running install
Checking .pth file support in /Library/Python/2.7/site-packages/
/usr/bin/python -E -c pass
TEST PASSED: /Library/Python/2.7/site-packages/ appears to support .pth files
running bdist_egg
running egg_info
writing requirements to src/sentiment_classifier.egg-info/requires.txt
writing src/sentiment_classifier.egg-info/PKG-INFO
writing top-level names to src/sentiment_classifier.egg-info/top_level.txt
writing dependency_links to src/sentiment_classifier.egg-info/dependency_links.txt
reading manifest file 'src/sentiment_classifier.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no directories found matching 'src/'
no previously-included directories found matching 'src/senti_classifier/.git/'
warning: no previously-included files found matching 'push.sh'
no previously-included directories found matching 'src/senti_classifier/_dicts'
writing manifest file 'src/sentiment_classifier.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.12-intel/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/senti_classifier
copying src/senti_classifier/__init__.py -> build/lib/senti_classifier
copying src/senti_classifier/classifiers.py -> build/lib/senti_classifier
copying src/senti_classifier/senti_classifier.py -> build/lib/senti_classifier
creating build/lib/senti_classifier/data
copying src/senti_classifier/data/__init__.py -> build/lib/senti_classifier/data
copying src/senti_classifier/data/sample_review.txt -> build/lib/senti_classifier/data
copying src/senti_classifier/data/SentiWordNet_3.0.0_20130122.txt -> build/lib/senti_classifier/data
copying src/senti_classifier/data/bag_of_words.p -> build/lib/senti_classifier/data
copying src/senti_classifier/data/SentiWn.p -> build/lib/senti_classifier/data
creating build/bdist.macosx-10.12-intel
creating build/bdist.macosx-10.12-intel/egg
creating build/bdist.macosx-10.12-intel/egg/senti_classifier
copying build/lib/senti_classifier/__init__.py -> build/bdist.macosx-10.12-intel/egg/senti_classifier
copying build/lib/senti_classifier/classifiers.py -> build/bdist.macosx-10.12-intel/egg/senti_classifier
creating build/bdist.macosx-10.12-intel/egg/senti_classifier/data
copying build/lib/senti_classifier/data/__init__.py -> build/bdist.macosx-10.12-intel/egg/senti_classifier/data
copying build/lib/senti_classifier/data/bag_of_words.p -> build/bdist.macosx-10.12-intel/egg/senti_classifier/data
copying build/lib/senti_classifier/data/sample_review.txt -> build/bdist.macosx-10.12-intel/egg/senti_classifier/data
copying build/lib/senti_classifier/data/SentiWn.p -> build/bdist.macosx-10.12-intel/egg/senti_classifier/data
copying build/lib/senti_classifier/data/SentiWordNet_3.0.0_20130122.txt -> build/bdist.macosx-10.12-intel/egg/senti_classifier/data
copying build/lib/senti_classifier/senti_classifier.py -> build/bdist.macosx-10.12-intel/egg/senti_classifier
byte-compiling build/bdist.macosx-10.12-intel/egg/senti_classifier/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.12-intel/egg/senti_classifier/classifiers.py to classifiers.pyc
byte-compiling build/bdist.macosx-10.12-intel/egg/senti_classifier/data/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.12-intel/egg/senti_classifier/senti_classifier.py to senti_classifier.pyc
creating build/bdist.macosx-10.12-intel/egg/EGG-INFO
installing scripts to build/bdist.macosx-10.12-intel/egg/EGG-INFO/scripts
running install_scripts
running build_scripts
creating build/scripts-2.7
copying and adjusting scripts/senti_classifier -> build/scripts-2.7
changing mode of build/scripts-2.7/senti_classifier from 644 to 755
creating build/bdist.macosx-10.12-intel/egg/EGG-INFO/scripts
copying build/scripts-2.7/senti_classifier -> build/bdist.macosx-10.12-intel/egg/EGG-INFO/scripts
changing mode of build/bdist.macosx-10.12-intel/egg/EGG-INFO/scripts/senti_classifier to 755
copying src/sentiment_classifier.egg-info/PKG-INFO -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying src/sentiment_classifier.egg-info/SOURCES.txt -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying src/sentiment_classifier.egg-info/dependency_links.txt -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying src/sentiment_classifier.egg-info/requires.txt -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
copying src/sentiment_classifier.egg-info/top_level.txt -> build/bdist.macosx-10.12-intel/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/sentiment_classifier-0.7-py2.7.egg' and adding 'build/bdist.macosx-10.12-intel/egg' to it
removing 'build/bdist.macosx-10.12-intel/egg' (and everything under it)
Processing sentiment_classifier-0.7-py2.7.egg
Copying sentiment_classifier-0.7-py2.7.egg to /Library/Python/2.7/site-packages
Adding sentiment-classifier 0.7 to easy-install.pth file
Installing senti_classifier script to /usr/local/bin

Installed /Library/Python/2.7/site-packages/sentiment_classifier-0.7-py2.7.egg
Processing dependencies for sentiment-classifier==0.7
Searching for argparse
Reading https://pypi.python.org/simple/argparse/
Best match: argparse 1.4.0
Downloading https://pypi.python.org/packages/18/dd/e617cfc3f6210ae183374cd9f6a26b20514bbb5a792af97949c5aacddf0f/argparse-1.4.0.tar.gz#md5=08062d2ceb6596fcbc5a7e725b53746f
Processing argparse-1.4.0.tar.gz
Writing /tmp/easy_install-tujkk3/argparse-1.4.0/setup.cfg
Running argparse-1.4.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-tujkk3/argparse-1.4.0/egg-dist-tmp-9wFaRv
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.orig' found anywhere in distribution
warning: no previously-included files matching '*.rej' found anywhere in distribution
no previously-included directories found matching 'doc/_build'
no previously-included directories found matching 'env24'
no previously-included directories found matching 'env25'
no previously-included directories found matching 'env26'
no previously-included directories found matching 'env27'
zip_safe flag not set; analyzing archive contents...
Copying argparse-1.4.0-py2.7.egg to /Library/Python/2.7/site-packages
Adding argparse 1.4.0 to easy-install.pth file

Installed /Library/Python/2.7/site-packages/argparse-1.4.0-py2.7.egg
Searching for nltk
Reading https://pypi.python.org/simple/nltk/
Best match: nltk 3.2.5
Downloading https://pypi.python.org/packages/cc/87/76e691bbf1759ad6af5831649aae6a8d2fa184a1bcc71018ca6300399e5f/nltk-3.2.5.tar.gz#md5=73a33f58da26a18e8d40ef630a40b599
Processing nltk-3.2.5.tar.gz
Writing /tmp/easy_install-9qjiTm/nltk-3.2.5/setup.cfg
Running nltk-3.2.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-9qjiTm/nltk-3.2.5/egg-dist-tmp-t2fOii
warning: no files found matching 'README.txt'
warning: no files found matching 'Makefile' under directory '*.txt'
warning: no previously-included files matching '*~' found anywhere in distribution
creating /Library/Python/2.7/site-packages/nltk-3.2.5-py2.7.egg
Extracting nltk-3.2.5-py2.7.egg to /Library/Python/2.7/site-packages
Adding nltk 3.2.5 to easy-install.pth file

Installed /Library/Python/2.7/site-packages/nltk-3.2.5-py2.7.egg
Searching for numpy==1.8.0rc1
Best match: numpy 1.8.0rc1
Adding numpy 1.8.0rc1 to easy-install.pth file

Using /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Searching for six==1.4.1
Best match: six 1.4.1
six 1.4.1 is already the active version in easy-install.pth

Using /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Finished processing dependencies for sentiment-classifier==0.7
➜  sentiment_classifier git:(master) ✗ python
Python 2.7.10 (default, Feb  6 2017, 23:53:20)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 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)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.12-intel/egg/senti_classifier/senti_classifier.py", line 235, in polarity_scores
  File "build/bdist.macosx-10.12-intel/egg/senti_classifier/senti_classifier.py", line 212, in classify
  File "build/bdist.macosx-10.12-intel/egg/senti_classifier/senti_classifier.py", line 174, in disambiguateWordSenses
  File "/Library/Python/2.7/site-packages/nltk-3.2.5-py2.7.egg/nltk/corpus/util.py", line 116, in __getattr__
    self.__load()
  File "/Library/Python/2.7/site-packages/nltk-3.2.5-py2.7.egg/nltk/corpus/util.py", line 81, in __load
    except LookupError: raise e
LookupError:
**********************************************************************
  Resource wordnet not found.
  Please use the NLTK Downloader to obtain the resource:

  >>> import nltk
  >>> nltk.download('wordnet')

  Searched in:
    - '/Users/kevincobain2000/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/local/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/local/lib/nltk_data'
    - '/System/Library/Frameworks/Python.framework/Versions/2.7/nltk_data'
    - '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/nltk_data'
**********************************************************************

>>> import nltk
>>> nltk.download('wordnet')
[nltk_data] Downloading package wordnet to
[nltk_data]     /Users/kevincobain2000/nltk_data...
[nltk_data]   Unzipping corpora/wordnet.zip.
True
>>> pos_score, neg_score = senti_classifier.polarity_scores(sentences)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.12-intel/egg/senti_classifier/senti_classifier.py", line 235, in polarity_scores
  File "build/bdist.macosx-10.12-intel/egg/senti_classifier/senti_classifier.py", line 212, in classify
  File "build/bdist.macosx-10.12-intel/egg/senti_classifier/senti_classifier.py", line 178, in disambiguateWordSenses
  File "/Library/Python/2.7/site-packages/nltk-3.2.5-py2.7.egg/nltk/tokenize/__init__.py", line 128, in word_tokenize
    sentences = [text] if preserve_line else sent_tokenize(text, language)
  File "/Library/Python/2.7/site-packages/nltk-3.2.5-py2.7.egg/nltk/tokenize/__init__.py", line 94, in sent_tokenize
    tokenizer = load('tokenizers/punkt/{0}.pickle'.format(language))
  File "/Library/Python/2.7/site-packages/nltk-3.2.5-py2.7.egg/nltk/data.py", line 834, in load
    opened_resource = _open(resource_url)
  File "/Library/Python/2.7/site-packages/nltk-3.2.5-py2.7.egg/nltk/data.py", line 952, in _open
    return find(path_, path + ['']).open()
  File "/Library/Python/2.7/site-packages/nltk-3.2.5-py2.7.egg/nltk/data.py", line 673, in find
    raise LookupError(resource_not_found)
LookupError:
**********************************************************************
  Resource punkt not found.
  Please use the NLTK Downloader to obtain the resource:

  >>> import nltk
  >>> nltk.download('punkt')

  Searched in:
    - '/Users/kevincobain2000/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/local/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/local/lib/nltk_data'
    - '/System/Library/Frameworks/Python.framework/Versions/2.7/nltk_data'
    - '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/nltk_data'
    - u''
**********************************************************************

>>> nltk.download('punkt')
[nltk_data] Downloading package punkt to
[nltk_data]     /Users/kevincobain2000/nltk_data...
[nltk_data]   Unzipping tokenizers/punkt.zip.
True
>>> pos_score, neg_score = senti_classifier.polarity_scores(sentences)
>>> print pos_score, neg_score
0.0 1.75