-
Notifications
You must be signed in to change notification settings - Fork 0
/
playground.py
60 lines (51 loc) · 2.88 KB
/
playground.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from darthVader.vaderSentimentu import SentimentIntensityAnalyzer
import darthVader.darth as d
# --- examples -------
sentences = ["VADER is smart, handsome, and funny.", # positive sentence example
"VADER is smart, handsome, and funny!", # punctuation emphasis handled correctly (sentiment intensity adjusted)
"VADER is very smart, handsome, and funny.", # booster words handled correctly (sentiment intensity adjusted)
"VADER is VERY SMART, handsome, and FUNNY.", # emphasis for ALLCAPS handled
"VADER is VERY SMART, handsome, and FUNNY!!!", # combination of signals - VADER appropriately adjusts intensity
"VADER is VERY SMART, uber handsome, and FRIGGIN FUNNY!!!", # booster words & punctuation make this close to ceiling for score
"VADER is not smart, handsome, nor funny.", # negation sentence example
"The book was good.", # positive sentence
"At least it isn't a horrible book.", # negated negative sentence with contraction
"The book was only kind of good.", # qualified positive sentence is handled correctly (intensity adjusted)
"The plot was good, but the characters are uncompelling and the dialog is not great.", # mixed negation sentence
"Today SUX!", # negative slang with capitalization emphasis
"Today only kinda sux! But I'll get by, lol", # mixed sentiment example with slang and constrastive conjunction "but"
"Make sure you :) or :D today!", # emoticons handled
"Catch utf-8 emoji such as such as 💘 and 💋 and 😁", # emojis handled
"Not bad at all", # Capitalized negation
"Watch the rose wilt." # Word not in the lexicon
]
from senticnet.senticnet import SenticNet
def vaderPlayground():
# sn = SenticNet()
# print(sn.polarity_value('love'))
analyzer = SentimentIntensityAnalyzer()
for sentence in sentences:
vs = analyzer.polarity_scores(sentence)
print("{:-<65} {}".format(sentence, str(vs)))
return
def darthPlayground():
darth = d.Darth()
#print(darth.closest_word("falling", ))
#print(darth.text_familiarity("wilt"))
#darth.learn_text_simple("wilt")
#print(darth.text_familiarity("wilt"))
#print(darth.vader.polarity_scores("wilt"))
for sentence in sentences:
darth.learn_text_simple(sentence)
vs = darth.vader.polarity_scores(sentence)
print("{:-<65} {}".format(sentence, str(vs)))
return
print("-------------------------------------------")
print("VADER Performance on Sentences:")
print("-------------------------------------------")
vaderPlayground()
print("-------------------------------------------")
print("DARTH-VADER Performance on Sentences:")
print("-------------------------------------------")
darthPlayground()
print("-------------------------------------------")