diff options
author | Chris Dyer <redpony@gmail.com> | 2014-02-27 19:45:14 -0500 |
---|---|---|
committer | Chris Dyer <redpony@gmail.com> | 2014-02-27 19:45:14 -0500 |
commit | 5675965782e2c9201a7a2fe54b542f5b06d660ef (patch) | |
tree | 2fefaf95c72f2caa72185e4579ad3b715e1cc5c4 /python/cdec/sa/features.py | |
parent | ed56625e5edeadbe9297680b07e269c42b7ea420 (diff) | |
parent | 53f4328e5e5cc72c6d483783edb85ba16b414caf (diff) |
Merge branch 'master' of https://github.com/redpony/cdec
Diffstat (limited to 'python/cdec/sa/features.py')
-rw-r--r-- | python/cdec/sa/features.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/python/cdec/sa/features.py b/python/cdec/sa/features.py index c8fc1cca..dcc60401 100644 --- a/python/cdec/sa/features.py +++ b/python/cdec/sa/features.py @@ -140,3 +140,14 @@ def IsSupportedOnline(ctx): # Occurs in online data? return (ctx.online.paircount > 0.01) else: return False + +def CountExceptLM(vocab): + def CountExceptLM(ctx): # Word count in bitext (inc online data) but NOT mono text + return sum(1 for e in ctx.ephrase.words if e not in vocab) + return CountExceptLM + +def CountExceptLex(ttable): + def CountExceptLex(ctx): # Word count in online data but NOT aligned in original bitext + # TODO: Check that online data actually contains aligned word when rulefactory TODO is addressed. + return sum(1 for e in ctx.ephrase.words if not ttable.contains_e_word(e)) + return CountExceptLex |