Clone wiki

pysentiwn / Home

A python interface to SentiWordNet (http://sentiwordnet.isti.cnr.it/).

The SentiWordNet is now available under CC BY SA 3.0 Licence. This Python scripts is an attempt provide an interface to SentiWordNet with NLTK wordnet module to obtain positive,negative and objective score.

How to use

1) Checkout the sentiwn.py file 2)

from sentiwn import SentiWordNet

sw = SentiWordNet("/home/jaggu/swn/SentiWordNet_3.0.0_20130122.txt")

senti_score = sw.get_score("good")

This will give u a list of dictionaries

[{'neg': 0.0, 'obj': 0.5, 'pos': 0.5, 'synset': Synset('good.n.01')},
 {'neg': 0.0, 'obj': 0.125, 'pos': 0.875, 'synset': Synset('good.n.02')},
 {'neg': 0.0, 'obj': 0.375, 'pos': 0.625, 'synset': Synset('good.n.03')},
 {'neg': 0.0, 'obj': 1.0, 'pos': 0.0, 'synset': Synset('commodity.n.01')},
 {'neg': 0.0, 'obj': 0.25, 'pos': 0.75, 'synset': Synset('good.a.01')},
 {'neg': 0.0, 'obj': 0.0, 'pos': 1.0, 'synset': Synset('good.a.03')},
 {'neg': 0.0, 'obj': 0.625, 'pos': 0.375, 'synset': Synset('well.r.01')},
 {'neg': 0.0, 'obj': 1.0, 'pos': 0.0, 'synset': Synset('thoroughly.r.02')}]

The synsets in the dictionary will help you to perform WSD with NLTK wornet module

Updated