Git Product home page Git Product logo

sentiment_classifier's Introduction

Citations

This library is sited here.

http://www.aclweb.org/anthology/W14-2708

iPhone App for Twitter Sentiments is Out

https://itunes.apple.com/us/app/emotion-calculator-for-twitter/id591404584?ls=1&mt=8

App no longer available. Sorry Due to lack of funds to run a seperate server App has been taken out of the app store. Use it free to build your own app tho

Sentiment Classification using WSD, Maximum Entropy & Naive Bayes Classifiers

Overview

Sentiment Classifier using Word Sense Disambiguation using wordnet and word occurance statistics from movie review corpus nltk. For twitter sentiment analysis bigrams are used as features on Naive Bayes and Maximum Entropy Classifier from the twitter data. Classifies into positive and negative labels. Next is use senses instead of tokens from the respective data.


sentiment_classifier-0.5.tar.gz

Download Stats Provided by pypi-github-stats

Sentiment Classifiers and Data

The above online demo uses movie review corpus from nltk, twitter and Amazon,on which Naive Bayes classifier is trained. Classifier using WSD SentiWordNet is based on heuristics and uses WordNet and SentiWordNet. Test results on sentiment analysis on twitter and amazon customer reviews data & features used for NaiveBayes will be Github.

Requirements

In Version 0.5 all the following requirements are installed automatically. In case of troubles install those manually.

How to Install

Shell command :

python setup.py install

Documentation

Script Usage

Shell Commands:

senti_classifier -c file/with/review.txt

Python Usage

Shell Commands :

cd sentiment_classifier/src/senti_classifier/
python senti_classifier.py -c reviews.txt

Library Usage

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

... 0.0 1.75
from senti_classifier.senti_classifier import synsets_scores
print synsets_scores['peaceful.a.01']['pos']

... 0.25

History

  • 0.7 Python 3.0 suport Thanks to @MrLokans
  • 0.6 Bug Fixed upon nltk upgrade
  • 0.5 No additional data required trained data is loaded automatically. Much faster/Optimized than previous versions.
  • 0.4 Added Bag of Words as a Feature as occurance statistics
  • 0.3 Sentiment Classifier First app, Using WSD module

sentiment_classifier's People

Contributors

jedirhymetrix avatar kevincobain2000 avatar mrlokans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sentiment_classifier's Issues

The performance is really slow. Is that normal?

Classifying text using the pickled classifiers is really slow. Like 6 seconds for a couple of sentences slow. Is it normal or am I doing something wrong? I'm following the README. Any tips to improve the performance?

Any Python 3 support?

It is currently impossible to analyze text with python 3, will it be difficult to adopt code for the third version of python?

Adding Acronyms in senti_classifer

Tried senti_classifier on some data to get sentiments of the sentences. It working fine for me. I still have two queries

  1. It doesn't work for acronyms, Curious to know how can we add some acronyms in the dictionary of this algorithm.
  2. Also, is there any way where it can handle negation?

Can you please let me know how can i overcome these? I am completely stuck at this point.

ModuleNotFoundError: No module named 'collections\r'

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_29176/1367208207.py in <module>
----> 1 from senti_classifier import senti_classifier

C:\Project_Files\Anaconda3\lib\site-packages\senti_classifier\senti_classifier.py in <module>
    227 senti_pickle = resource_stream('senti_classifier', 'data/SentiWn.p')
    228 bag_of_words_pickle = resource_stream('senti_classifier', 'data/bag_of_words.p')
--> 229 synsets_scores = pickle.load(senti_pickle)
    230 bag_of_words = pickle.load(bag_of_words_pickle)
    231 bag_of_words = classify_polarity(bag_of_words)

ModuleNotFoundError: No module named 'collections\r'

I have tried pip install sentiment_classifier though pip install was successful, it didn't pull any files. So I referred to the Stack overflow post https://stackoverflow.com/questions/48521208/nltk-sentiment-classifier-issues-with-install and cloned GitHub repo and replaced the files into the senti_classifier folder. Now I get the above error .

Using Anaconda, Python 3.8, Windows 11

Getting 0,0 score after pulling the latest code from current branch

Hi,

I am using sentiment_classifier in my project. I installed and importing in my script. but for all sentences it is getting 0,0 scores. I referred to last issue and verified if code version is latest and it is.

Can you help.

Attaching code and screenshot:

Code:
pos_score, neg_score = senti_classifier.polarity_scores('The movie was the worst movie')
print("Positive Score")
print(pos_score)
print("Negative Score")
print(neg_score)

Screenshot:
capture_senti

Trouble with Example Code

I'm trying to run:

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

but i keep getting error

Traceback (most recent call last):
  File "/home/robbie/sentiment/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'

it looks like i don't have some sort of data file? Where do I get one or how do I make one? I thought it was already trained upon install.

SentiWn.p

File "site-packages/pkg_resources/init.py", line 1576, in get_resource_stream
return open(self._fn(self.module_path, resource_name), 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'python3.5/site-packages/senti_classifier/data/SentiWn.p'

All scores are (0,0)

Hi,

I have used senti_classifier before and it worked fine. However, I had reinstalled it and since then it is giving zero score for anything and everything. Can anyone please help?

Question about data training part

Hi, I'm recently working on a project about sentiment analysis, and I would like to take this project as a reference. May I know where to input training data and how SentiWn.p is trained? Thanks a lot.

pip install fails to add ".p" files on version 0.7

pip install fails to add ".p" files on version 0.7 which leads to the error:

"FileNotFoundError: [Errno 2] No such file or directory: '...lib/python3.6/site-packages/senti_classifier/data/SentiWn.p'"

On downloading the latest build from https://pypi.python.org/pyp... and extracting, the "src/senti_classifier/data/" directory is missing the ".p" files. PyPi needs update.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.