forked from cjhutto/vaderSentiment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtinker2.py
52 lines (41 loc) · 1.2 KB
/
tinker2.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
import nltk
from nltk.corpus import wordnet as wn
from nltk.corpus.reader import wordnet
import vaderSentiment
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
analyzer = SentimentIntensityAnalyzer()
w = 'astonish'
for s in wn.synsets(w):
print(s.lemma_names(),s.definition())
defn = s.definition()
sto = []
for sh in s.similar_tos():
sto += sh.lemma_names()
print(sto)
hypo = []
for sh in s.hyponyms():
hypo += sh.lemma_names()
print(hypo)
hype = []
for sh in s.hypernyms():
hype += sh.lemma_names()
print(hype)
i_hypo = []
for sh in s.instance_hyponyms():
i_hypo += sh.lemma_names()
print(i_hypo)
i_hype = []
for sh in s.instance_hypernyms():
i_hype += sh.lemma_names()
print(i_hype)
es = []
#for sh in s.eq_synonym():
# es += sh/lemma_names()
# print(es)
xdfn = '; '.join([defn]+sto+hypo+hype+i_hype+i_hypo)
print(xdfn)
print(analyzer.polarity_scores(xdfn)['compound'])
print(analyzer.polarity_scores(defn)['compound'])
print(analyzer.polarity_scores(w))
# differentiate by POS to find the right lemma?
# using ntlk.pos_tag