Sentiment Classification using WSD, Maximum Entropy & Naive Bayes Classifiers

Overview

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
Comments
  • All scores are (0,0)

    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?

    opened by ayushidalmia 8
  • Trouble with Example Code

    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.

    opened by robbiebarrat 4
  • Getting 0,0 score after pulling the latest code from current branch

    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

    opened by prasadpande1990 4
  • pip install fails to add

    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.

    opened by codez266 3
  • Adding Acronyms in senti_classifer

    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.

    opened by harshalchopde 2
  • SentiWn.p

    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'

    opened by Pooort 2
  • Minor optimizations

    Minor optimizations

    In addition to this, does polarity_scores() expect a paragraph string or a list of sentences? Because if it's the latter, there is more scope for optimization as an entire for loop can be removed.

    opened by JediRhymeTrix 1
  • The performance is really slow. Is that normal?

    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?

    opened by JediRhymeTrix 1
  • Question about data training part

    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.

    opened by pcy0710d 1
  • Getting No module named Collections error in senti_classifier line 229

    Getting No module named Collections error in senti_classifier line 229

    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

    opened by chaitralikulkarni 1
  • Python 3 support.

    Python 3 support.

    I've cleaned up code a little bit for it to correspond PEP-8 best-practices, transformed it into python2/3 cross-compatible and wrote a simplistic utility for regression testing.

    opened by MrLokans 1
  • ModuleNotFoundError: No module named 'collections\r'

    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

    opened by medasuryatej 4
Owner
Pulkit Kathuria
Pulkit Kathuria
C.J. Hutto 2.8k Feb 18, 2021
Twitter-Sentiment-Analysis - Twitter sentiment analysis for india's top online retailers(2019 to 2022)

Twitter-Sentiment-Analysis Twitter sentiment analysis for india's top online retailers(2019 to 2022) Project Overview : Sentiment Analysis helps us to

Balaji R 1 Jan 1, 2022
Code for Findings of ACL 2022 Paper "Sentiment Word Aware Multimodal Refinement for Multimodal Sentiment Analysis with ASR Errors"

SWRM Code for Findings of ACL 2022 Paper "Sentiment Word Aware Multimodal Refinement for Multimodal Sentiment Analysis with ASR Errors" Clone Clone th

null 14 Jan 3, 2023
This is a general repo that helps you develop fast/effective NLP classifiers using Huggingface

NLP Classifier Introduction This project trains a bert model on any NLP classifcation model. And uses the model in make predictions on new data using

Abdullah Tarek 3 Mar 11, 2022
Unsupervised Language Modeling at scale for robust sentiment classification

** DEPRECATED ** This repo has been deprecated. Please visit Megatron-LM for our up to date Large-scale unsupervised pretraining and finetuning code.

NVIDIA Corporation 1k Nov 17, 2022
IMDB film review sentiment classification based on BERT's supervised learning model.

IMDB film review sentiment classification based on BERT's supervised learning model. On the other hand, the model can be extended to other natural language multi-classification tasks.

Paris 1 Apr 17, 2022
Implemented shortest-circuit disambiguation, maximum probability disambiguation, HMM-based lexical annotation and BiLSTM+CRF-based named entity recognition

Implemented shortest-circuit disambiguation, maximum probability disambiguation, HMM-based lexical annotation and BiLSTM+CRF-based named entity recognition

null 0 Feb 13, 2022
Product-Review-Summarizer - Created a product review summarizer which clustered thousands of product reviews and summarized them into a maximum of 500 characters, saving precious time of customers and helping them make a wise buying decision.

Product-Review-Summarizer - Created a product review summarizer which clustered thousands of product reviews and summarized them into a maximum of 500 characters, saving precious time of customers and helping them make a wise buying decision.

Parv Bhatt 1 Jan 1, 2022
Summarization, translation, sentiment-analysis, text-generation and more at blazing speed using a T5 version implemented in ONNX.

Summarization, translation, Q&A, text generation and more at blazing speed using a T5 version implemented in ONNX. This package is still in alpha stag

Abel 211 Dec 28, 2022
Summarization, translation, sentiment-analysis, text-generation and more at blazing speed using a T5 version implemented in ONNX.

Summarization, translation, Q&A, text generation and more at blazing speed using a T5 version implemented in ONNX. This package is still in alpha stag

Abel 137 Feb 1, 2021
A combination of autoregressors and autoencoders using XLNet for sentiment analysis

A combination of autoregressors and autoencoders using XLNet for sentiment analysis Abstract In this paper sentiment analysis has been performed in or

James Zaridis 2 Nov 20, 2021
Sentiment Analysis Project using Count Vectorizer and TF-IDF Vectorizer

Sentiment Analysis Project This project contains two sentiment analysis programs for Hotel Reviews using a Hotel Reviews dataset from Datafiniti. The

Simran Farrukh 0 Mar 28, 2022
An example project using OpenPrompt under pytorch-lightning for prompt-based SST2 sentiment analysis model

pl_prompt_sst An example project using OpenPrompt under the framework of pytorch-lightning for a training prompt-based text classification model on SS

Zhiling Zhang 5 Oct 21, 2022
Twitter Sentiment Analysis using #tag, words and username

Twitter Sentment Analysis Web App using #tag, words and username to fetch data finds Insides of data and Tells Sentiment of the perticular #tag, words or username.

Kumar Saksham 26 Dec 25, 2022
Ptorch NLU, a Chinese text classification and sequence annotation toolkit, supports multi class and multi label classification tasks of Chinese long text and short text, and supports sequence annotation tasks such as Chinese named entity recognition, part of speech tagging and word segmentation.

Pytorch-NLU,一个中文文本分类、序列标注工具包,支持中文长文本、短文本的多类、多标签分类任务,支持中文命名实体识别、词性标注、分词等序列标注任务。 Ptorch NLU, a Chinese text classification and sequence annotation toolkit, supports multi class and multi label classification tasks of Chinese long text and short text, and supports sequence annotation tasks such as Chinese named entity recognition, part of speech tagging and word segmentation.

null 186 Dec 24, 2022
multi-label,classifier,text classification,多标签文本分类,文本分类,BERT,ALBERT,multi-label-classification,seq2seq,attention,beam search

multi-label,classifier,text classification,多标签文本分类,文本分类,BERT,ALBERT,multi-label-classification,seq2seq,attention,beam search

hellonlp 30 Dec 12, 2022
Simple, Pythonic, text processing--Sentiment analysis, part-of-speech tagging, noun phrase extraction, translation, and more.

TextBlob: Simplified Text Processing Homepage: https://textblob.readthedocs.io/ TextBlob is a Python (2 and 3) library for processing textual data. It

Steven Loria 8.4k Dec 26, 2022
Simple, Pythonic, text processing--Sentiment analysis, part-of-speech tagging, noun phrase extraction, translation, and more.

TextBlob: Simplified Text Processing Homepage: https://textblob.readthedocs.io/ TextBlob is a Python (2 and 3) library for processing textual data. It

Steven Loria 7.5k Feb 17, 2021