-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathVADERgetScore.py
More file actions
39 lines (30 loc) · 891 Bytes
/
VADERgetScore.py
File metadata and controls
39 lines (30 loc) · 891 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
import pandas
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
hit = 0
miss = 0
sizeList = 1100
def nullGen(n):
return ([0] * n)
sentimentValue = nullGen(sizeList)
vs = nullGen(sizeList)
prediction = nullGen(sizeList)
analyzer = SentimentIntensityAnalyzer()
classified = pandas.read_csv('classifyCSV.csv')
comments = pandas.read_csv('comments.csv')
comments = comments.rename(columns={'' : '0','Video is crazy - but song sucks.': '1'})
def morph(value):
if value > 0.5:
return 1
if value < 0.5:
return -1
else:
return 0
for x in range(0,1095):
vs[x] = analyzer.polarity_scores(comments['1'][x])
sentimentValue[x] = vs[x]['compound']
prediction[x] = morph(sentimentValue[x])
if classified['1'][x] == prediction[x]:
hit = hit + 1
if classified['1'][x] != prediction[x]:
miss = miss + 1
print (hit / (hit+miss))