summaryrefslogtreecommitdiff
path: root/python/src/grammar.pxi
diff options
context:
space:
mode:
authorVictor Chahuneau <vchahune@cs.cmu.edu>2012-07-30 00:04:02 -0400
committerVictor Chahuneau <vchahune@cs.cmu.edu>2012-07-30 00:04:02 -0400
commit3325742971681642adadfac180f8e0e27014bd57 (patch)
tree3d4b96d22875a42ef0c5074fce92d800911bca09 /python/src/grammar.pxi
parentc7d1b04980d9d90458625a7f8e92985c7409a78d (diff)
[python] monolingual grammars
Diffstat (limited to 'python/src/grammar.pxi')
-rw-r--r--python/src/grammar.pxi12
1 files changed, 12 insertions, 0 deletions
diff --git a/python/src/grammar.pxi b/python/src/grammar.pxi
index 59266238..a9a5ea14 100644
--- a/python/src/grammar.pxi
+++ b/python/src/grammar.pxi
@@ -166,6 +166,18 @@ cdef class TRule:
return '%s ||| %s ||| %s ||| %s' % (self.lhs,
_phrase(self.f), _phrase(self.e), scores)
+cdef class MRule(TRule):
+ def __init__(self, lhs, rhs, scores, a=None):
+ cdef unsigned i = 1
+ e = []
+ for s in rhs:
+ if isinstance(s, NT):
+ e.append(NTRef(i))
+ i += 1
+ else:
+ e.append(s)
+ super(MRule, self).__init__(lhs, rhs, e, scores, a)
+
cdef class Grammar:
cdef shared_ptr[grammar.Grammar]* grammar