sentiwordnet lexicon the wordnet corpus is definitely one of the most popular corpora for the english language used extensively in natural language processing and semantic analysis wordnet gave us the concept of synsets or synonym sets the sentiwordnet lexicon is based on wordnet synsets and can be used for sentiment analysis and opinion mining the sentiwordnet lexicon typically assigns three sentiment scores for each wordnet synset these include positive polarity scorea negative polarity score and an objectivity score further details are available on the official web site download links for the lexicon we will be using the nltk librarywhich provides pythonic interface into sentiwordnet consider we have the adjective awesome we can get the sentiment scores associated with the synset for this word using the following snippet in [ ]from nltk corpus import sentiwordnet as swn awesome list(swn senti_synsets('awesome'' '))[ print('positive polarity score:'awesome pos_score()print('negative polarity score:'awesome neg_score()print('objective score:'awesome obj_score()positive polarity score negative polarity score objective score let' now build generic function to extract and aggregate sentiment scores for complete textual document based on matched synsets in that document def analyze_sentiment_sentiwordnet_lexicon(reviewverbose=false)tokenize and pos tag text tokens tagged_text [(token texttoken tag_for token in tn nlp(review)pos_score neg_score token_count obj_score get wordnet synsets based on pos tags get sentiment scores if synsets are found for wordtag in tagged_textss_set none if 'nnin tag and list(swn senti_synsets(word' '))ss_set list(swn senti_synsets(word' '))[ elif 'vbin tag and list(swn senti_synsets(word' '))ss_set list(swn senti_synsets(word' '))[ elif 'jjin tag and list(swn senti_synsets(word' '))ss_set list(swn senti_synsets(word' '))[ elif 'rbin tag and list(swn senti_synsets(word' '))ss_set list(swn senti_synsets(word' '))[ if senti-synset is found if ss_setadd scores for all found synsets pos_score +ss_set pos_score(neg_score +ss_set neg_score(obj_score +ss_set obj_score(token_count +