Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using WN-Affect to detect emotion/mood of a string

I downloaded WN-Affect. I am however not sure how to use it to detect the mood of a sentence. For example if I have a string "I hate football." I want to be able to detect whether the mood is bad and the emotion is fear. WN-Affect has no tutorial on how to do it, and I am kind of new to python. Any help would be great!

like image 783
user3078335 Avatar asked Jan 14 '15 12:01

user3078335


2 Answers

In short: Use SentiWordNet instead and look at https://github.com/kevincobain2000/sentiment_classifier


In Long:

Affectedness vs Sentiment

The line between affect and sentiment is very fine. One should looking into Affectedness in linguistics studies, e.g. http://compling.hss.ntu.edu.sg/events/2014-ws-affectedness/ and Sentiment Analysis in computational researches. For now, let's call both the task of identifying affect and sentiment, sentiment analysis.

Also note that WN-Affect is a rather old resource compared to SentiWordNet, http://sentiwordnet.isti.cnr.it/.

Here's a good resource for using SentiWordNet for sentiment analysis: https://github.com/kevincobain2000/sentiment_classifier.

Often sentiment analysis has only two classes, positive or negative sentiment. Whereas the WN-affect uses 11 types of affectedness labels:

  • emotion
  • mood
  • trait
  • cognitive state
  • physical state
  • hedonic signal
  • emotion-eliciting
  • emotional response
  • behaviour
  • attitude
  • sensation

For each type, there are multiple classes, see https://github.com/larsmans/wordnet-domains-sentiwords/blob/master/wn-domains/wn-affect-1.1/a-hierarchy.xml


To answer the question of how one can use the WN-Affect, there're several things you need to do:

First map WN1.6 to WN3.0 (it's not an easy task, you have to do several mappings, especially the mapping between 2.0-2.1)

Now using the WN-Affect with WN3.0, you can apply

  • the same classification technique as he SentiWordNet sentiment classifier or
  • try to maximize the classes within text and then use some heuristics to choose 'positive' / 'negative'
like image 130
alvas Avatar answered Nov 16 '22 02:11

alvas


WordNet-Affect uses WordNet 1.6 offsets.

However, WordNet 1.6 is still available for download. You can use the nltk.corpus.WordNetCorpusReader class to load it. I wrote all the code to do it here.

like image 24
clemtoy Avatar answered Nov 16 '22 00:11

clemtoy