-
Notifications
You must be signed in to change notification settings - Fork 2
/
GRAPH OF OPINION MINING.PY
64 lines (38 loc) · 1.26 KB
/
GRAPH OF OPINION MINING.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
61
62
63
64
# -*- coding: utf-8 -*-
"""
@author: YASH
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
def graph(c):
har=[0,0,0,0,0,0]
for i in c:
if i=='Happiness':
har[0]+=1
elif i=='Anger':
har[1]+=1
elif i=='Neutral':
har[5]+=1
elif i=='Fear':
har[2]+=1
elif i=='Sadness':
har[3]+=1
elif i=='Disgust':
har[4]+=1
s=float(sum(har))
for i in range(len(har)):
har[i]=har[i]/s
return har
harvard=pd.read_csv("FINAL_Harvard_SENTIMENTS.csv")
mit=pd.read_csv("FINAL_MIT_SENTIMENTS.csv")
stanford=pd.read_csv("FINAL_Stanford_SENTIMENTS.csv")
har=graph(harvard['Sentiment'].values)
mit=graph(mit['Sentiment'].values)
stan=graph(stanford['Sentiment'].values)
Index=['Happiness','Anger','Fear','Sadness','Disgust','Neutral']
gr={'Harvard':har,'MIT':mit,'Stanford':stan}
qw=pd.DataFrame(gr,index=Index)
qw.plot(y=["Harvard","MIT", "Stanford"],kind="bar")
y.label='Number of tweets'
plt.show()