nltk.corpus.reader.sentiwordnet module

An NLTK interface for SentiWordNet

SentiWordNet is a lexical resource for opinion mining. SentiWordNet assigns to each synset of WordNet three sentiment scores: positivity, negativity, and objectivity.

For details about SentiWordNet see: http://sentiwordnet.isti.cnr.it/

>>> from nltk.corpus import sentiwordnet as swn
>>> print(swn.senti_synset('breakdown.n.03'))
<breakdown.n.03: PosScore=0.0 NegScore=0.25>
>>> list(swn.senti_synsets('slow'))
[SentiSynset('decelerate.v.01'), SentiSynset('slow.v.02'), SentiSynset('slow.v.03'), SentiSynset('slow.a.01'), SentiSynset('slow.a.02'), SentiSynset('dense.s.04'), SentiSynset('slow.a.04'), SentiSynset('boring.s.01'), SentiSynset('dull.s.08'), SentiSynset('slowly.r.01'), SentiSynset('behind.r.03')]
>>> happy = swn.senti_synsets('happy', 'a')
>>> happy0 = list(happy)[0]
>>> happy0.pos_score()
0.875
>>> happy0.neg_score()
0.0
>>> happy0.obj_score()
0.125
class nltk.corpus.reader.sentiwordnet.SentiSynset[source]

Bases: object

__init__(pos_score, neg_score, synset)[source]
neg_score()[source]
obj_score()[source]
pos_score()[source]
class nltk.corpus.reader.sentiwordnet.SentiWordNetCorpusReader[source]

Bases: CorpusReader

__init__(root, fileids, encoding='utf-8')[source]

Construct a new SentiWordNet Corpus Reader, using data from the specified file.

all_senti_synsets()[source]
senti_synset(*vals)[source]
senti_synsets(string, pos=None)[source]