diff options
Diffstat (limited to 'src/query_comparer.py')
-rw-r--r-- | src/query_comparer.py | 31 |
1 files changed, 31 insertions, 0 deletions
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() |