pythonnltksentiment-analysisnamed-entity-extraction

NLTK sentiment towards entity


I have just started using NLTK and the task I need to accomplish is pretty simple, I think. I need to parse a number of documents and extract the sentiment towards some entities. For example the overall sentiment of the following sentence:

Tea is great. However, I hate coffee.

is negative, but I would like to extract the sentiment towards single, predefined entities. In particular, in the previous example I would like to feed NLTK with my entities ('tea', 'coffee') and be able to extract sentiment('tea') and sentiment('coffee') separately. I read through this document but I could not find a way to accomplish this simple task.


Solution

  • You need a classifier, and you need an annotated sentiment corpus to train it with. The nltk offers the movie_review corpus, but of course you'll get best results if you train with something similar to your own data. See also the nltk's nltk.sentiment package.