diff options
author | Patrick Simianer <p@simianer.de> | 2014-06-12 13:56:42 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-06-12 13:56:42 +0200 |
commit | 244971287003d079e46193b8a209c28955f90134 (patch) | |
tree | 8beaae6b12b913acb213fc7f2415fd63886192f9 /python/cdec/sa/online.py | |
parent | 5250fd67a4b8f242068cff87f0a6a4211f8b0fcf (diff) | |
parent | b66e838ed52decc0be1eb5817b2a77c3840db2c5 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'python/cdec/sa/online.py')
-rw-r--r-- | python/cdec/sa/online.py | 14 |
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 |