summaryrefslogtreecommitdiff
path: root/python/cdec/sa/online.py
diff options
context:
space:
mode:
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