-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathnrc_play.py
More file actions
46 lines (26 loc) · 708 Bytes
/
Copy pathnrc_play.py
File metadata and controls
46 lines (26 loc) · 708 Bytes
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
def parse_nrc():
word_emotion_dict={}
f=open("NRC-Emotion-Lexicon-Senselevel-v0.92.txt")
list_lines= f.readlines()
word_emotion_dict={}
for line in list_lines:
splitted= line.split("--")
word=splitted[0]
word_emotion_dict[word]={}
for line in list_lines:
splitted= line.split("--")
word=splitted[0]
splitted2= splitted[1].split("\t")
emot_score=splitted2[-1].strip("\n")
emot=splitted2[-2]
word_emotion_dict[word][emot]= emot_score
#print(splitted2)
#print(emot)
#print(emot_score)
return(word_emotion_dict)
if __name__=="__main__":
d= parse_nrc()
print(len(d))
for word in d:
if d[word]["positive"]== '1' and d[word]["sadness"]=='1':
print(word)