summaryrefslogtreecommitdiff
path: root/python/cdec/sa/features.py
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-06-12 13:56:42 +0200
committerPatrick Simianer <p@simianer.de>2014-06-12 13:56:42 +0200
commit244971287003d079e46193b8a209c28955f90134 (patch)
tree8beaae6b12b913acb213fc7f2415fd63886192f9 /python/cdec/sa/features.py
parent5250fd67a4b8f242068cff87f0a6a4211f8b0fcf (diff)
parentb66e838ed52decc0be1eb5817b2a77c3840db2c5 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'python/cdec/sa/features.py')
-rw-r--r--python/cdec/sa/features.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/python/cdec/sa/features.py b/python/cdec/sa/features.py
index 1779f2f9..92e23889 100644
--- a/python/cdec/sa/features.py
+++ b/python/cdec/sa/features.py
@@ -3,6 +3,8 @@ import math
from cdec.sa import isvar
+from online import get_score_multilex
+
MAXSCORE = 99
def EgivenF(ctx): # p(e|f) = c(e, f)/c(f)
@@ -46,7 +48,10 @@ def MaxLexEgivenF(ttable):
fwords.append('NULL')
maxOffScore = 0.0
for e in ctx.ephrase.words:
- maxScore = max(ttable.get_score(f, e, 0) for f in fwords)
+ if ctx.online:
+ maxScore = max(get_score_multilex(f, e, 0, (ttable, ctx.online.bilex)) for f in fwords)
+ else:
+ maxScore = max(ttable.get_score(f, e, 0) for f in fwords)
maxOffScore += -math.log10(maxScore) if maxScore > 0 else MAXSCORE
return maxOffScore
return MaxLexEgivenF
@@ -57,7 +62,10 @@ def MaxLexFgivenE(ttable):
ewords.append('NULL')
maxOffScore = 0.0
for f in ctx.fphrase.words:
- maxScore = max(ttable.get_score(f, e, 1) for e in ewords)
+ if ctx.online:
+ maxScore = max(get_score_multilex(f, e, 1, (ttable, ctx.online.bilex)) for e in ewords)
+ else:
+ maxScore = max(ttable.get_score(f, e, 1) for e in ewords)
maxOffScore += -math.log10(maxScore) if maxScore > 0 else MAXSCORE
return maxOffScore
return MaxLexFgivenE