-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprobalilistic_tagger.py
47 lines (44 loc) · 1.21 KB
/
probalilistic_tagger.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
# A simple probablistic tagger
# The goal is to beat this accuracy using ML
import analytics,corpus
statistic = analytics.load_analytics()
heighest_probabilty = {}
for i in statistic:
heighest_probabilty[i] = max(statistic[i].items(),key=lambda x:x[1])[0]
test = corpus.load_corpus(last=True)
test_dict = []
for i in test:
for j in i:
test_dict.append(j)
hit = 0
miss = 0
unknwon = 0
ambiguity_miss = 0
unknwon_ambiguity = 0
a = 1
for i in test_dict:
try:
if heighest_probabilty[i[0]] == i[1]:
hit+=1
else:
if i[1] in statistic[i[0]]:
ambiguity_miss+=1
miss+=1
else:
if len(statistic[i[0]].keys())==1:
a+=1
print("ambigity:",statistic[i[0]],i)
unknwon_ambiguity+=1
miss+=1
except KeyError:
miss+=1
unknwon+=1
print(a)
print("accuracy:", hit/(hit+miss))
print("total:",(hit+miss))
print("ambiguity_miss",ambiguity_miss)
print("unknown:", unknwon)
print("unknown ambiguity",unknwon_ambiguity)
print("total hit,total miss(including unkown and ambiguity):", hit,miss)
#print(heighest_probabilty["मेरो"])
#print(test_dict)