-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevaltagging2.py
55 lines (38 loc) · 983 Bytes
/
evaltagging2.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
import pymysql
from nltk.corpus import stopwords
conn=pymysql.connect(host='127.0.0.1',user='root', passwd='root',port=8889,db='AlgebraNationWall')
a = conn.cursor()
sql = 'SELECT id, predictedTags, ManualTag FROM PostTagging_test4;'
a.execute(sql)
#countrow = a.execute(sql)
#print ("Number of rows :",countrow)
#data = a.fetchall()
b = conn.cursor()
totcount = 0
correctCount = 0
try:
for row in a:
predictedTags = row[1]
ManualTag = row[2]
#fetch all the tags
#loop over all the (top 2/3/4/5) tags and see if they match with ManualTag
if predictedTag==ManualTag:
evalp = "Y"
correctCount+=1
else:
evalp = "N"
sql2 = "UPDATE PostTagging_test4 SET PredCorrect = %s where id ="+str(row[0])+";"
flag = b.execute(sql2, (evalp))
print flag
totcount+=1
except Exception as e:
raise
print(e)
else:
pass
finally:
pass
conn.commit()
print "Accuracy of Prediction is :"+ str(correctCount) +" / "+str(totcount)
#print (a)
#print(data)