summaryrefslogtreecommitdiff
path: root/python/cdec/sa/online.py
diff options
context:
space:
mode:
authormjdenkowski <michael.j.denkowski@gmail.com>2014-04-10 16:58:46 -0400
committermjdenkowski <michael.j.denkowski@gmail.com>2014-04-10 16:58:46 -0400
commit659ea32efb9ad0c1d8ad0d1dc4ead67be9859e6b (patch)
tree09c1a368701d55c87eaf4b846368ec315da33282 /python/cdec/sa/online.py
parent1014d39fa347ec51dd2e588bae16b8692e188382 (diff)
Refactoring
Diffstat (limited to 'python/cdec/sa/online.py')
-rw-r--r--python/cdec/sa/online.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/python/cdec/sa/online.py b/python/cdec/sa/online.py
index d3f967e8..98c3459b 100644
--- a/python/cdec/sa/online.py
+++ b/python/cdec/sa/online.py
@@ -126,3 +126,17 @@ class Bilex:
break
(f, e, c) = line.split()
self.fe[(f, e)] = float(c)
+
+# Bilex get_score for multiple instances
+def get_score_multilex(f, e, dir, bilex_list):
+ num = 0
+ denom = 0
+ for bilex in bilex_list:
+ if dir == 0:
+ denom += bilex.f.get(f, 0)
+ else:
+ denom += bilex.e.get(e, 0)
+ num += bilex.fe.get((f, e), 0)
+ if (not num) or (not denom):
+ return None
+ return num / denom