diff options
author | Patrick Simianer <p@simianer.de> | 2014-06-12 13:56:42 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-06-12 13:56:42 +0200 |
commit | 244971287003d079e46193b8a209c28955f90134 (patch) | |
tree | 8beaae6b12b913acb213fc7f2415fd63886192f9 /python/cdec/grammar.pxi | |
parent | 5250fd67a4b8f242068cff87f0a6a4211f8b0fcf (diff) | |
parent | b66e838ed52decc0be1eb5817b2a77c3840db2c5 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'python/cdec/grammar.pxi')
-rw-r--r-- | python/cdec/grammar.pxi | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/python/cdec/grammar.pxi b/python/cdec/grammar.pxi index d523e4d2..b78c86ff 100644 --- a/python/cdec/grammar.pxi +++ b/python/cdec/grammar.pxi @@ -49,7 +49,7 @@ cdef TRule convert_rule(_sa.Rule rule): cdef class TRule: cdef shared_ptr[grammar.TRule]* rule - def __init__(self, lhs, f, e, scores, a=None): + def __init__(self, lhs, f, e, scores, a=None, text=None): """TRule(lhs, f, e, scores, a=None) -> Translation rule. lhs: left hand side non-terminal f: source phrase (list of words/NT) @@ -57,12 +57,18 @@ cdef class TRule: scores: dictionary of feature scores a: optional list of alignment points""" self.rule = new shared_ptr[grammar.TRule](new grammar.TRule()) - self.lhs = lhs - self.e = e - self.f = f - self.scores = scores + if lhs: + self.lhs = lhs + if e: + self.e = e + if f: + self.f = f + if scores: + self.scores = scores if a: - self.a = a + self.a = a + if text: + self.rule.get().ReadFromString(text, 0) self.rule.get().ComputeArity() def __dealloc__(self): |