summaryrefslogtreecommitdiff
path: root/python/cdec/sa/features.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/cdec/sa/features.py')
-rw-r--r--python/cdec/sa/features.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/python/cdec/sa/features.py b/python/cdec/sa/features.py
index 8d35d8e6..325b9e13 100644
--- a/python/cdec/sa/features.py
+++ b/python/cdec/sa/features.py
@@ -1,6 +1,5 @@
from __future__ import division
import math
-import cdec.sa
MAXSCORE = 99
@@ -22,11 +21,10 @@ def CoherenceProb(fphrase, ephrase, paircount, fcount, fsample_count):
def MaxLexEgivenF(ttable):
def feature(fphrase, ephrase, paircount, fcount, fsample_count):
- fwords = [cdec.sa.sym_tostring(w) for w in fphrase if not cdec.sa.sym_isvar(w)]
+ fwords = fphrase.words
fwords.append('NULL')
- ewords = (cdec.sa.sym_tostring(w) for w in ephrase if not cdec.sa.sym_isvar(w))
def score():
- for e in ewords:
+ for e in ephrase.words:
maxScore = max(ttable.get_score(f, e, 0) for f in fwords)
yield -math.log10(maxScore) if maxScore > 0 else MAXSCORE
return sum(score())
@@ -34,11 +32,10 @@ def MaxLexEgivenF(ttable):
def MaxLexFgivenE(ttable):
def feature(fphrase, ephrase, paircount, fcount, fsample_count):
- fwords = (cdec.sa.sym_tostring(w) for w in fphrase if not cdec.sa.sym_isvar(w))
- ewords = [cdec.sa.sym_tostring(w) for w in ephrase if not cdec.sa.sym_isvar(w)]
+ ewords = ephrase.words
ewords.append('NULL')
def score():
- for f in fwords:
+ for f in fphrase.words:
maxScore = max(ttable.get_score(f, e, 1) for e in ewords)
yield -math.log10(maxScore) if maxScore > 0 else MAXSCORE
return sum(score())