blob: 79b9905528e570e2282ba85a0672334dc6cef284 (
plain)
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
|
class QueryComparer:
def __init__(self, config):
self.config = config
def run(self):
hyp_file = open('%s/hyp.fun' % self.config.experiment_dir)
ref_file = open('%s/test.fun' % self.config.experiment_dir)
out_file = open('%s/eval.scored' % self.config.experiment_dir, 'w')
hyps = {}
for line in hyp_file:
idx, hyp, scores1, scores2 = line.split(' ||| ')
hyps[int(idx)] = hyp
i = -1
for line in ref_file:
i += 1
if i not in hyps:
print >>out_file, 'empty'
continue
test = line.strip()
if hyps[i] == test:
print >>out_file, 'yes', 0
else:
print >>out_file, 'no', 0
hyp_file.close()
ref_file.close()
out_file.close()
|