From f343459d6198352964dbb6779f15c352fe2d5794 Mon Sep 17 00:00:00 2001 From: Jacob Date: Sun, 28 Jul 2013 09:54:54 +0100 Subject: init --- src/query_comparer.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/query_comparer.py (limited to 'src/query_comparer.py') diff --git a/src/query_comparer.py b/src/query_comparer.py new file mode 100644 index 0000000..79b9905 --- /dev/null +++ b/src/query_comparer.py @@ -0,0 +1,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() -- cgit v1.2.3