summaryrefslogtreecommitdiff
path: root/src/query_comparer.py
diff options
context:
space:
mode:
authorJacob <andqso@gmail.com>2013-07-28 09:54:54 +0100
committerJacob <andqso@gmail.com>2013-07-28 09:54:54 +0100
commitf343459d6198352964dbb6779f15c352fe2d5794 (patch)
tree07d50c9a8269e3892ccea8f5680b3e2bac984fce /src/query_comparer.py
init
Diffstat (limited to 'src/query_comparer.py')
-rw-r--r--src/query_comparer.py31
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()