from senticnet.senticnet import Senticnet sn = Senticnet() print "polarity:", sn.polarity('love') print "semantics:", " ".join(sn.semantics('love')) print "\n".join([key + ": " + str(value) for key, value in sn.sentics('love').items()])
__author__ = 'cloudera' from senticnet.senticnet import Senticnet from textblob import TextBlob sentence = "One of the very first Apple 1 computers, worth about 500,000, goes on sale later this month at Christie's auction house, the latest vintage tech sale." sn = Senticnet() concept_info = sn.concept('love') print 'sn.concept(love) = ', concept_info polarity = sn.polarity('love') print 'polarity(love) = ', polarity semantics = sn.semantics('love') print 'semantics = ', semantics sentics = sn.sentics('love') print 'sentics = ', sentics sentenceBlob = TextBlob(sentence) print sentenceBlob.parse() print sentenceBlob.sentiment sentenceConcept = sn.concept(sentence) print sentenceConcept
from senticnet.senticnet import Senticnet sn = Senticnet() print "polarity:", sn.polarity('love') print "semantics:", " ".join(sn.semantics('love')) print "\n".join( [key + ": " + str(value) for key, value in sn.sentics('love').items()])
# print sentences ## instantiate senticnet sn = Senticnet() counter = 0 total = 0 words = re.compile('\w+').findall(sentences) for word in words: word = word.lower() try: print word polarity = sn.polarity(word) counter += 1 total += polarity # print counter, word, polarity except: pass except: break # Print average polarity score avg_polarity = total / counter print avg_polarity total_avg_polarity += avg_polarity # # Print the ratio between the summary length and the original length