-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathconllu-col-eval.py
More file actions
45 lines (35 loc) · 816 Bytes
/
conllu-col-eval.py
File metadata and controls
45 lines (35 loc) · 816 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
import sys ;
ref = open(sys.argv[1]);
tst = open(sys.argv[2]);
col = int(sys.argv[3]);
total = 0.0;
correct = 0.0;
errors = 0.0;
while True: #{
ref_l = ref.readline();
tst_l = tst.readline();
if ref_l == '' and tst_l == '': #{
break;
#}
if ref_l == '\n' and tst_l == '\n': #{
continue;
#}
if ref_l[0] == '#' and tst_l[0] == '#':#{
continue;
#}
ref_r = ref_l.split('\t');
tst_r = tst_l.split('\t');
if ref_r[1] != tst_r[1]: #{
print('ERROR: Unaligned', file=sys.stderr);
print(ref_r, file=sys.stderr);
print(tst_r, file=sys.stderr);
break;
#}
if ref_r[1] == tst_r[1] and ref_r[col] == tst_r[col]: #{
correct = correct + 1.0;
elif ref_r[1] == tst_r[1] and ref_r[col] != tst_r[col]: #{
errors = errors + 1.0;
#}
total = total + 1.0
#}
print('%.2f' % (correct/total*100.0));