summaryrefslogtreecommitdiff
path: root/python/cdec/sa/features.py
diff options
context:
space:
mode:
authorChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2014-02-26 00:03:48 -0500
committerChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2014-02-26 00:03:48 -0500
commit1cb85d42d12bdbe21f9f258fa50fcc1c73e8cfcc (patch)
treeac2f498f686be4e532c94b3d01537757f90d38f0 /python/cdec/sa/features.py
parent7c0ee6a2e22a1ace580ed1dcad65a4c591783135 (diff)
parent3cb43f4e3980457cbb7b749cee51a5bb777e18f8 (diff)
Merge branch 'master' of github.com:redpony/cdec
Diffstat (limited to 'python/cdec/sa/features.py')
-rw-r--r--python/cdec/sa/features.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/python/cdec/sa/features.py b/python/cdec/sa/features.py
index c8fc1cca..f5cbdb8d 100644
--- a/python/cdec/sa/features.py
+++ b/python/cdec/sa/features.py
@@ -140,3 +140,13 @@ 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 original bitext
+ return sum(1 for e in ctx.ephrase.words if not ttable.contains_e_word(e))
+ return CountExceptLex