summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/pkg/cdec/__init__.py2
-rw-r--r--python/src/_cdec.cpp588
-rw-r--r--python/src/grammar.pxi12
3 files changed, 549 insertions, 53 deletions
diff --git a/python/pkg/cdec/__init__.py b/python/pkg/cdec/__init__.py
index 503ac787..531fea49 100644
--- a/python/pkg/cdec/__init__.py
+++ b/python/pkg/cdec/__init__.py
@@ -1 +1 @@
-from cdec._cdec import Decoder, Lattice, TRule, NT, NTRef, ParseFailed, InvalidConfig
+from cdec._cdec import Decoder, Lattice, TRule, MRule, NT, NTRef, ParseFailed, InvalidConfig
diff --git a/python/src/_cdec.cpp b/python/src/_cdec.cpp
index 88c03520..dcd33448 100644
--- a/python/src/_cdec.cpp
+++ b/python/src/_cdec.cpp
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.17.beta1 on Sat Jul 28 20:10:21 2012 */
+/* Generated by Cython 0.17.beta1 on Sun Jul 29 23:00:27 2012 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -417,6 +417,7 @@ struct __pyx_obj_5_cdec_CandidateSet;
struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__;
struct __pyx_obj_5_cdec_TRule;
struct __pyx_obj_4cdec_2sa_3_sa_Rule;
+struct __pyx_obj_5_cdec_MRule;
struct __pyx_obj_5_cdec_SegmentEvaluator;
struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__;
struct __pyx_obj_5_cdec_Candidate;
@@ -535,8 +536,8 @@ struct __pyx_obj_4cdec_2sa_3_sa_Phrase {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":169
- * _phrase(self.f), _phrase(self.e), scores)
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":181
+ * super(MRule, self).__init__(lhs, rhs, e, scores, a)
*
* cdef class Grammar: # <<<<<<<<<<<<<<
* cdef shared_ptr[grammar.Grammar]* grammar
@@ -652,6 +653,18 @@ struct __pyx_obj_4cdec_2sa_3_sa_Rule {
};
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":169
+ * _phrase(self.f), _phrase(self.e), scores)
+ *
+ * cdef class MRule(TRule): # <<<<<<<<<<<<<<
+ * def __init__(self, lhs, rhs, scores, a=None):
+ * cdef unsigned i = 1
+ */
+struct __pyx_obj_5_cdec_MRule {
+ struct __pyx_obj_5_cdec_TRule __pyx_base;
+};
+
+
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":98
* self.cs.AddKBestCandidates(hypergraph.hg[0], k, self.scorer.get())
*
@@ -898,7 +911,7 @@ struct __pyx_obj_5_cdec_DenseVector {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":175
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":187
* del self.grammar
*
* def __iter__(self): # <<<<<<<<<<<<<<
@@ -1136,7 +1149,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":192
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":204
* self.grammar.get().SetGrammarName(string(<char *>name))
*
* cdef class TextGrammar(Grammar): # <<<<<<<<<<<<<<
@@ -1693,6 +1706,7 @@ static PyTypeObject *__pyx_ptype_5_cdec_SparseVector = 0;
static PyTypeObject *__pyx_ptype_5_cdec_NT = 0;
static PyTypeObject *__pyx_ptype_5_cdec_NTRef = 0;
static PyTypeObject *__pyx_ptype_5_cdec_TRule = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_MRule = 0;
static PyTypeObject *__pyx_ptype_5_cdec_Grammar = 0;
static PyTypeObject *__pyx_ptype_5_cdec_TextGrammar = 0;
static PyTypeObject *__pyx_ptype_5_cdec_Hypergraph = 0;
@@ -1746,6 +1760,7 @@ static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_NotImplemented;
+static PyObject *__pyx_builtin_super;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_eval;
static PyObject *__pyx_builtin_enumerate;
@@ -1810,6 +1825,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_3lhs___get__(struct __pyx_obj_5_cdec_TRu
static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_lhs); /* proto */
static PyObject *__pyx_pf_5_cdec_5TRule_7__str___genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_rhs, PyObject *__pyx_v_scores, PyObject *__pyx_v_a); /* proto */
static void __pyx_pf_5_cdec_7Grammar___dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Grammar *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5_cdec_7Grammar_2__iter__(struct __pyx_obj_5_cdec_Grammar *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5_cdec_7Grammar_4name___get__(struct __pyx_obj_5_cdec_Grammar *__pyx_v_self); /* proto */
@@ -1952,6 +1968,7 @@ static char __pyx_k__key[] = "key";
static char __pyx_k__lhs[] = "lhs";
static char __pyx_k__plf[] = "plf";
static char __pyx_k__ref[] = "ref";
+static char __pyx_k__rhs[] = "rhs";
static char __pyx_k__BLEU[] = "BLEU";
static char __pyx_k__eval[] = "eval";
static char __pyx_k__info[] = "info";
@@ -1973,6 +1990,7 @@ static char __pyx_k__rules[] = "rules";
static char __pyx_k__score[] = "score";
static char __pyx_k__split[] = "split";
static char __pyx_k__strip[] = "strip";
+static char __pyx_k__super[] = "super";
static char __pyx_k__value[] = "value";
static char __pyx_k__config[] = "config";
static char __pyx_k__csplit[] = "csplit";
@@ -1990,6 +2008,7 @@ static char __pyx_k__replace[] = "replace";
static char __pyx_k__IBM_BLEU[] = "IBM_BLEU";
static char __pyx_k__KeyError[] = "KeyError";
static char __pyx_k____exit__[] = "__exit__";
+static char __pyx_k____init__[] = "__init__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____name__[] = "__name__";
static char __pyx_k____test__[] = "__test__";
@@ -2070,6 +2089,7 @@ static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s____class__;
static PyObject *__pyx_n_s____enter__;
static PyObject *__pyx_n_s____exit__;
+static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____name__;
static PyObject *__pyx_n_s____test__;
@@ -2124,6 +2144,7 @@ static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__ref;
static PyObject *__pyx_n_s__refs;
static PyObject *__pyx_n_s__replace;
+static PyObject *__pyx_n_s__rhs;
static PyObject *__pyx_n_s__rules;
static PyObject *__pyx_n_s__scfg;
static PyObject *__pyx_n_s__score;
@@ -2134,6 +2155,7 @@ static PyObject *__pyx_n_s__span;
static PyObject *__pyx_n_s__split;
static PyObject *__pyx_n_s__startswith;
static PyObject *__pyx_n_s__strip;
+static PyObject *__pyx_n_s__super;
static PyObject *__pyx_n_s__tagger;
static PyObject *__pyx_n_s__utf8;
static PyObject *__pyx_n_s__value;
@@ -7706,7 +7728,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule *
* return '%s ||| %s ||| %s ||| %s' % (self.lhs,
* _phrase(self.f), _phrase(self.e), scores) # <<<<<<<<<<<<<<
*
- * cdef class Grammar:
+ * cdef class MRule(TRule):
*/
__pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
@@ -7774,6 +7796,292 @@ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule *
}
/* Python wrapper */
+static int __pyx_pw_5_cdec_5MRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5_cdec_5MRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ PyObject *__pyx_v_lhs = 0;
+ PyObject *__pyx_v_rhs = 0;
+ PyObject *__pyx_v_scores = 0;
+ PyObject *__pyx_v_a = 0;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+ {
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__lhs,&__pyx_n_s__rhs,&__pyx_n_s__scores,&__pyx_n_s__a,0};
+ PyObject* values[4] = {0,0,0,0};
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":170
+ *
+ * cdef class MRule(TRule):
+ * def __init__(self, lhs, rhs, scores, a=None): # <<<<<<<<<<<<<<
+ * cdef unsigned i = 1
+ * e = []
+ */
+ values[3] = ((PyObject *)Py_None);
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args;
+ const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+ switch (pos_args) {
+ case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+ case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+ case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ kw_args = PyDict_Size(__pyx_kwds);
+ switch (pos_args) {
+ case 0:
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lhs)) != 0)) kw_args--;
+ else goto __pyx_L5_argtuple_error;
+ case 1:
+ if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__rhs)) != 0)) kw_args--;
+ else {
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ case 2:
+ if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scores)) != 0)) kw_args--;
+ else {
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ case 3:
+ if (kw_args > 0) {
+ PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__a);
+ if (value) { values[3] = value; kw_args--; }
+ }
+ }
+ if (unlikely(kw_args > 0)) {
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ } else {
+ switch (PyTuple_GET_SIZE(__pyx_args)) {
+ case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+ case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+ values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ }
+ __pyx_v_lhs = values[0];
+ __pyx_v_rhs = values[1];
+ __pyx_v_scores = values[2];
+ __pyx_v_a = values[3];
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L5_argtuple_error:;
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("_cdec.MRule.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return -1;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_5MRule___init__(((struct __pyx_obj_5_cdec_MRule *)__pyx_v_self), __pyx_v_lhs, __pyx_v_rhs, __pyx_v_scores, __pyx_v_a);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_rhs, PyObject *__pyx_v_scores, PyObject *__pyx_v_a) {
+ unsigned int __pyx_v_i;
+ PyObject *__pyx_v_e = NULL;
+ PyObject *__pyx_v_s = NULL;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ Py_ssize_t __pyx_t_2;
+ PyObject *(*__pyx_t_3)(PyObject *);
+ PyObject *__pyx_t_4 = NULL;
+ int __pyx_t_5;
+ PyObject *__pyx_t_6 = NULL;
+ int __pyx_t_7;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__init__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":171
+ * cdef class MRule(TRule):
+ * def __init__(self, lhs, rhs, scores, a=None):
+ * cdef unsigned i = 1 # <<<<<<<<<<<<<<
+ * e = []
+ * for s in rhs:
+ */
+ __pyx_v_i = 1;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":172
+ * def __init__(self, lhs, rhs, scores, a=None):
+ * cdef unsigned i = 1
+ * e = [] # <<<<<<<<<<<<<<
+ * for s in rhs:
+ * if isinstance(s, NT):
+ */
+ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_v_e = __pyx_t_1;
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":173
+ * cdef unsigned i = 1
+ * e = []
+ * for s in rhs: # <<<<<<<<<<<<<<
+ * if isinstance(s, NT):
+ * e.append(NTRef(i))
+ */
+ if (PyList_CheckExact(__pyx_v_rhs) || PyTuple_CheckExact(__pyx_v_rhs)) {
+ __pyx_t_1 = __pyx_v_rhs; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+ __pyx_t_3 = NULL;
+ } else {
+ __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
+ }
+ for (;;) {
+ if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
+ #else
+ __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
+ #else
+ __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_4 = __pyx_t_3(__pyx_t_1);
+ if (unlikely(!__pyx_t_4)) {
+ if (PyErr_Occurred()) {
+ if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
+ else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_4);
+ }
+ __Pyx_XDECREF(__pyx_v_s);
+ __pyx_v_s = __pyx_t_4;
+ __pyx_t_4 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":174
+ * e = []
+ * for s in rhs:
+ * if isinstance(s, NT): # <<<<<<<<<<<<<<
+ * e.append(NTRef(i))
+ * i += 1
+ */
+ __pyx_t_4 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT));
+ __Pyx_INCREF(__pyx_t_4);
+ __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_s, __pyx_t_4);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ if (__pyx_t_5) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":175
+ * for s in rhs:
+ * if isinstance(s, NT):
+ * e.append(NTRef(i)) # <<<<<<<<<<<<<<
+ * i += 1
+ * else:
+ */
+ __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
+ __Pyx_GIVEREF(__pyx_t_4);
+ __pyx_t_4 = 0;
+ __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+ __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":176
+ * if isinstance(s, NT):
+ * e.append(NTRef(i))
+ * i += 1 # <<<<<<<<<<<<<<
+ * else:
+ * e.append(s)
+ */
+ __pyx_v_i = (__pyx_v_i + 1);
+ goto __pyx_L5;
+ }
+ /*else*/ {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":178
+ * i += 1
+ * else:
+ * e.append(s) # <<<<<<<<<<<<<<
+ * super(MRule, self).__init__(lhs, rhs, e, scores, a)
+ *
+ */
+ __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_v_s); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ __pyx_L5:;
+ }
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":179
+ * else:
+ * e.append(s)
+ * super(MRule, self).__init__(lhs, rhs, e, scores, a) # <<<<<<<<<<<<<<
+ *
+ * cdef class Grammar:
+ */
+ __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_MRule)));
+ PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_MRule)));
+ __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_MRule)));
+ __Pyx_INCREF(((PyObject *)__pyx_v_self));
+ PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self));
+ __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
+ __pyx_t_4 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __pyx_t_4 = PyTuple_New(5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_INCREF(__pyx_v_lhs);
+ PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_lhs);
+ __Pyx_GIVEREF(__pyx_v_lhs);
+ __Pyx_INCREF(__pyx_v_rhs);
+ PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_rhs);
+ __Pyx_GIVEREF(__pyx_v_rhs);
+ __Pyx_INCREF(((PyObject *)__pyx_v_e));
+ PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_e));
+ __Pyx_GIVEREF(((PyObject *)__pyx_v_e));
+ __Pyx_INCREF(__pyx_v_scores);
+ PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_scores);
+ __Pyx_GIVEREF(__pyx_v_scores);
+ __Pyx_INCREF(__pyx_v_a);
+ PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_v_a);
+ __Pyx_GIVEREF(__pyx_v_a);
+ __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_AddTraceback("_cdec.MRule.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_e);
+ __Pyx_XDECREF(__pyx_v_s);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
static void __pyx_pw_5_cdec_7Grammar_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_5_cdec_7Grammar_1__dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannyDeclarations
@@ -7782,7 +8090,7 @@ static void __pyx_pw_5_cdec_7Grammar_1__dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannyFinishContext();
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":172
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":184
* cdef shared_ptr[grammar.Grammar]* grammar
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
@@ -7794,7 +8102,7 @@ static void __pyx_pf_5_cdec_7Grammar___dealloc__(CYTHON_UNUSED struct __pyx_obj_
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":173
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":185
*
* def __dealloc__(self):
* del self.grammar # <<<<<<<<<<<<<<
@@ -7818,7 +8126,7 @@ static PyObject *__pyx_pw_5_cdec_7Grammar_3__iter__(PyObject *__pyx_v_self) {
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":175
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":187
* del self.grammar
*
* def __iter__(self): # <<<<<<<<<<<<<<
@@ -7844,7 +8152,7 @@ static PyObject *__pyx_pf_5_cdec_7Grammar_2__iter__(struct __pyx_obj_5_cdec_Gram
__Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
__Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
{
- __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Grammar_4generator3, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Grammar_4generator3, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -7879,9 +8187,9 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p
return NULL;
}
__pyx_L3_first_run:;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":176
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":188
*
* def __iter__(self):
* cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot() # <<<<<<<<<<<<<<
@@ -7890,7 +8198,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p
*/
__pyx_cur_scope->__pyx_v_root = __pyx_cur_scope->__pyx_v_self->grammar->get()->GetRoot();
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":177
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":189
* def __iter__(self):
* cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot()
* cdef grammar.const_RuleBin* rbin = root.GetRules() # <<<<<<<<<<<<<<
@@ -7899,7 +8207,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p
*/
__pyx_cur_scope->__pyx_v_rbin = __pyx_cur_scope->__pyx_v_root->GetRules();
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":180
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":192
* cdef TRule trule
* cdef unsigned i
* for i in range(rbin.GetNumRules()): # <<<<<<<<<<<<<<
@@ -7910,23 +8218,23 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p
for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
__pyx_cur_scope->__pyx_v_i = __pyx_t_2;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":181
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":193
* cdef unsigned i
* for i in range(rbin.GetNumRules()):
* trule = TRule.__new__(TRule) # <<<<<<<<<<<<<<
* trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i))
* yield trule
*/
- __pyx_t_3 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_TRule)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_TRule)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- if (!(likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_trule));
__Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_trule));
__Pyx_GIVEREF(__pyx_t_3);
__pyx_cur_scope->__pyx_v_trule = ((struct __pyx_obj_5_cdec_TRule *)__pyx_t_3);
__pyx_t_3 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":182
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":194
* for i in range(rbin.GetNumRules()):
* trule = TRule.__new__(TRule)
* trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i)) # <<<<<<<<<<<<<<
@@ -7935,7 +8243,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p
*/
__pyx_cur_scope->__pyx_v_trule->rule = new boost::shared_ptr<TRule>(__pyx_cur_scope->__pyx_v_rbin->GetIthRule(__pyx_cur_scope->__pyx_v_i));
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":183
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":195
* trule = TRule.__new__(TRule)
* trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i))
* yield trule # <<<<<<<<<<<<<<
@@ -7954,7 +8262,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p
__pyx_L6_resume_from_yield:;
__pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
__pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
@@ -7980,7 +8288,7 @@ static PyObject *__pyx_pw_5_cdec_7Grammar_4name_1__get__(PyObject *__pyx_v_self)
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":186
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":198
*
* property name:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -7993,7 +8301,7 @@ static PyObject *__pyx_pf_5_cdec_7Grammar_4name___get__(struct __pyx_obj_5_cdec_
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":187
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":199
* property name:
* def __get__(self):
* self.grammar.get().GetGrammarName().c_str() # <<<<<<<<<<<<<<
@@ -8019,7 +8327,7 @@ static int __pyx_pw_5_cdec_7Grammar_4name_3__set__(PyObject *__pyx_v_self, PyObj
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":189
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":201
* self.grammar.get().GetGrammarName().c_str()
*
* def __set__(self, name): # <<<<<<<<<<<<<<
@@ -8036,14 +8344,14 @@ static int __pyx_pf_5_cdec_7Grammar_4name_2__set__(struct __pyx_obj_5_cdec_Gramm
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__set__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":190
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":202
*
* def __set__(self, name):
* self.grammar.get().SetGrammarName(string(<char *>name)) # <<<<<<<<<<<<<<
*
* cdef class TextGrammar(Grammar):
*/
- __pyx_t_1 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_self->grammar->get()->SetGrammarName(std::string(((char *)__pyx_t_1)));
__pyx_r = 0;
@@ -8081,7 +8389,7 @@ static int __pyx_pw_5_cdec_11TextGrammar_1__cinit__(PyObject *__pyx_v_self, PyOb
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
goto __pyx_L5_argtuple_error;
@@ -8092,7 +8400,7 @@ static int __pyx_pw_5_cdec_11TextGrammar_1__cinit__(PyObject *__pyx_v_self, PyOb
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("_cdec.TextGrammar.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
@@ -8103,7 +8411,7 @@ static int __pyx_pw_5_cdec_11TextGrammar_1__cinit__(PyObject *__pyx_v_self, PyOb
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":193
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":205
*
* cdef class TextGrammar(Grammar):
* def __cinit__(self, rules): # <<<<<<<<<<<<<<
@@ -8128,7 +8436,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__cinit__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":194
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":206
* cdef class TextGrammar(Grammar):
* def __cinit__(self, rules):
* self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) # <<<<<<<<<<<<<<
@@ -8137,7 +8445,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG
*/
__pyx_v_self->__pyx_base.grammar = new boost::shared_ptr<Grammar>(new TextGrammar());
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":195
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":207
* def __cinit__(self, rules):
* self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar())
* cdef grammar.TextGrammar* _g = <grammar.TextGrammar*> self.grammar.get() # <<<<<<<<<<<<<<
@@ -8146,7 +8454,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG
*/
__pyx_v__g = ((TextGrammar *)__pyx_v_self->__pyx_base.grammar->get());
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":196
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":208
* self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar())
* cdef grammar.TextGrammar* _g = <grammar.TextGrammar*> self.grammar.get()
* for trule in rules: # <<<<<<<<<<<<<<
@@ -8157,7 +8465,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG
__pyx_t_1 = __pyx_v_rules; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
__pyx_t_3 = NULL;
} else {
- __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rules); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rules); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
}
@@ -8167,21 +8475,21 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
#else
- __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
#endif
} else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) {
if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
#if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
#else
- __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
#endif
} else {
__pyx_t_4 = __pyx_t_3(__pyx_t_1);
if (unlikely(!__pyx_t_4)) {
if (PyErr_Occurred()) {
if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
- else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
break;
}
@@ -8191,7 +8499,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG
__pyx_v_trule = __pyx_t_4;
__pyx_t_4 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":197
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":209
* cdef grammar.TextGrammar* _g = <grammar.TextGrammar*> self.grammar.get()
* for trule in rules:
* if isinstance(trule, _sa.Rule): # <<<<<<<<<<<<<<
@@ -8204,17 +8512,17 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
if (__pyx_t_5) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":198
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":210
* for trule in rules:
* if isinstance(trule, _sa.Rule):
* trule = convert_rule(trule) # <<<<<<<<<<<<<<
* elif not isinstance(trule, TRule):
* raise ValueError('the grammar should contain TRule objects')
*/
- if (!(likely(((__pyx_v_trule) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_trule, __pyx_ptype_4cdec_2sa_3_sa_Rule))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(((__pyx_v_trule) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_trule, __pyx_ptype_4cdec_2sa_3_sa_Rule))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_4 = __pyx_v_trule;
__Pyx_INCREF(__pyx_t_4);
- __pyx_t_6 = ((PyObject *)__pyx_f_5_cdec_convert_rule(((struct __pyx_obj_4cdec_2sa_3_sa_Rule *)__pyx_t_4))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = ((PyObject *)__pyx_f_5_cdec_convert_rule(((struct __pyx_obj_4cdec_2sa_3_sa_Rule *)__pyx_t_4))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_v_trule);
@@ -8223,7 +8531,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG
goto __pyx_L5;
}
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":199
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":211
* if isinstance(trule, _sa.Rule):
* trule = convert_rule(trule)
* elif not isinstance(trule, TRule): # <<<<<<<<<<<<<<
@@ -8237,22 +8545,22 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG
__pyx_t_7 = (!__pyx_t_5);
if (__pyx_t_7) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":200
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":212
* trule = convert_rule(trule)
* elif not isinstance(trule, TRule):
* raise ValueError('the grammar should contain TRule objects') # <<<<<<<<<<<<<<
* _g.AddRule((<TRule> trule).rule[0])
*/
- __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_Raise(__pyx_t_6, 0, 0, 0);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- {__pyx_filename = __pyx_f[2]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[2]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":201
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":213
* elif not isinstance(trule, TRule):
* raise ValueError('the grammar should contain TRule objects')
* _g.AddRule((<TRule> trule).rule[0]) # <<<<<<<<<<<<<<
@@ -19428,6 +19736,174 @@ static PyTypeObject __pyx_type_5_cdec_TRule = {
#endif
};
+static PyObject *__pyx_tp_new_5_cdec_MRule(PyTypeObject *t, PyObject *a, PyObject *k) {
+ PyObject *o = __pyx_tp_new_5_cdec_TRule(t, a, k);
+ if (!o) return 0;
+ return o;
+}
+
+static PyMethodDef __pyx_methods_5_cdec_MRule[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_MRule = {
+ 0, /*nb_add*/
+ 0, /*nb_subtract*/
+ 0, /*nb_multiply*/
+ #if PY_MAJOR_VERSION < 3
+ 0, /*nb_divide*/
+ #endif
+ 0, /*nb_remainder*/
+ 0, /*nb_divmod*/
+ 0, /*nb_power*/
+ 0, /*nb_negative*/
+ 0, /*nb_positive*/
+ 0, /*nb_absolute*/
+ 0, /*nb_nonzero*/
+ 0, /*nb_invert*/
+ 0, /*nb_lshift*/
+ 0, /*nb_rshift*/
+ 0, /*nb_and*/
+ 0, /*nb_xor*/
+ 0, /*nb_or*/
+ #if PY_MAJOR_VERSION < 3
+ 0, /*nb_coerce*/
+ #endif
+ 0, /*nb_int*/
+ #if PY_MAJOR_VERSION < 3
+ 0, /*nb_long*/
+ #else
+ 0, /*reserved*/
+ #endif
+ 0, /*nb_float*/
+ #if PY_MAJOR_VERSION < 3
+ 0, /*nb_oct*/
+ #endif
+ #if PY_MAJOR_VERSION < 3
+ 0, /*nb_hex*/
+ #endif
+ 0, /*nb_inplace_add*/
+ 0, /*nb_inplace_subtract*/
+ 0, /*nb_inplace_multiply*/
+ #if PY_MAJOR_VERSION < 3
+ 0, /*nb_inplace_divide*/
+ #endif
+ 0, /*nb_inplace_remainder*/
+ 0, /*nb_inplace_power*/
+ 0, /*nb_inplace_lshift*/
+ 0, /*nb_inplace_rshift*/
+ 0, /*nb_inplace_and*/
+ 0, /*nb_inplace_xor*/
+ 0, /*nb_inplace_or*/
+ 0, /*nb_floor_divide*/
+ 0, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ 0, /*nb_inplace_true_divide*/
+ #if PY_VERSION_HEX >= 0x02050000
+ 0, /*nb_index*/
+ #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_MRule = {
+ 0, /*sq_length*/
+ 0, /*sq_concat*/
+ 0, /*sq_repeat*/
+ 0, /*sq_item*/
+ 0, /*sq_slice*/
+ 0, /*sq_ass_item*/
+ 0, /*sq_ass_slice*/
+ 0, /*sq_contains*/
+ 0, /*sq_inplace_concat*/
+ 0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_MRule = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_MRule = {
+ #if PY_MAJOR_VERSION < 3
+ 0, /*bf_getreadbuffer*/
+ #endif
+ #if PY_MAJOR_VERSION < 3
+ 0, /*bf_getwritebuffer*/
+ #endif
+ #if PY_MAJOR_VERSION < 3
+ 0, /*bf_getsegcount*/
+ #endif
+ #if PY_MAJOR_VERSION < 3
+ 0, /*bf_getcharbuffer*/
+ #endif
+ #if PY_VERSION_HEX >= 0x02060000
+ 0, /*bf_getbuffer*/
+ #endif
+ #if PY_VERSION_HEX >= 0x02060000
+ 0, /*bf_releasebuffer*/
+ #endif
+};
+
+static PyTypeObject __pyx_type_5_cdec_MRule = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.MRule"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_MRule), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_TRule, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ #if PY_MAJOR_VERSION < 3
+ 0, /*tp_compare*/
+ #else
+ 0, /*reserved*/
+ #endif
+ 0, /*tp_repr*/
+ &__pyx_tp_as_number_MRule, /*tp_as_number*/
+ &__pyx_tp_as_sequence_MRule, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_MRule, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ #if CYTHON_COMPILING_IN_PYPY
+ __pyx_pw_5_cdec_5TRule_5__str__, /*tp_str*/
+ #else
+ 0, /*tp_str*/
+ #endif
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_MRule, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_MRule, /*tp_methods*/
+ 0, /*tp_members*/
+ 0, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ __pyx_pw_5_cdec_5MRule_1__init__, /*tp_init*/
+ 0, /*tp_alloc*/
+ __pyx_tp_new_5_cdec_MRule, /*tp_new*/
+ 0, /*tp_free*/
+ 0, /*tp_is_gc*/
+ 0, /*tp_bases*/
+ 0, /*tp_mro*/
+ 0, /*tp_cache*/
+ 0, /*tp_subclasses*/
+ 0, /*tp_weaklist*/
+ 0, /*tp_del*/
+ #if PY_VERSION_HEX >= 0x02060000
+ 0, /*tp_version_tag*/
+ #endif
+};
+
static PyObject *__pyx_tp_new_5_cdec_Grammar(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -27070,6 +27546,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s____class__, __pyx_k____class__, sizeof(__pyx_k____class__), 0, 0, 1, 1},
{&__pyx_n_s____enter__, __pyx_k____enter__, sizeof(__pyx_k____enter__), 0, 0, 1, 1},
{&__pyx_n_s____exit__, __pyx_k____exit__, sizeof(__pyx_k____exit__), 0, 0, 1, 1},
+ {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
{&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
{&__pyx_n_s____name__, __pyx_k____name__, sizeof(__pyx_k____name__), 0, 0, 1, 1},
{&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
@@ -27124,6 +27601,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s__ref, __pyx_k__ref, sizeof(__pyx_k__ref), 0, 0, 1, 1},
{&__pyx_n_s__refs, __pyx_k__refs, sizeof(__pyx_k__refs), 0, 0, 1, 1},
{&__pyx_n_s__replace, __pyx_k__replace, sizeof(__pyx_k__replace), 0, 0, 1, 1},
+ {&__pyx_n_s__rhs, __pyx_k__rhs, sizeof(__pyx_k__rhs), 0, 0, 1, 1},
{&__pyx_n_s__rules, __pyx_k__rules, sizeof(__pyx_k__rules), 0, 0, 1, 1},
{&__pyx_n_s__scfg, __pyx_k__scfg, sizeof(__pyx_k__scfg), 0, 0, 1, 1},
{&__pyx_n_s__score, __pyx_k__score, sizeof(__pyx_k__score), 0, 0, 1, 1},
@@ -27134,6 +27612,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
{&__pyx_n_s__startswith, __pyx_k__startswith, sizeof(__pyx_k__startswith), 0, 0, 1, 1},
{&__pyx_n_s__strip, __pyx_k__strip, sizeof(__pyx_k__strip), 0, 0, 1, 1},
+ {&__pyx_n_s__super, __pyx_k__super, sizeof(__pyx_k__super), 0, 0, 1, 1},
{&__pyx_n_s__tagger, __pyx_k__tagger, sizeof(__pyx_k__tagger), 0, 0, 1, 1},
{&__pyx_n_s__utf8, __pyx_k__utf8, sizeof(__pyx_k__utf8), 0, 0, 1, 1},
{&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1},
@@ -27146,7 +27625,8 @@ static int __Pyx_InitCachedBuiltins(void) {
__pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_NotImplemented = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplemented); if (!__pyx_builtin_NotImplemented) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_super = __Pyx_GetName(__pyx_b, __pyx_n_s__super); if (!__pyx_builtin_super) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_eval = __Pyx_GetName(__pyx_b, __pyx_n_s__eval); if (!__pyx_builtin_eval) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_enumerate = __Pyx_GetName(__pyx_b, __pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_IndexError = __Pyx_GetName(__pyx_b, __pyx_n_s__IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -27202,13 +27682,13 @@ static int __Pyx_InitCachedConstants(void) {
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6));
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":200
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":212
* trule = convert_rule(trule)
* elif not isinstance(trule, TRule):
* raise ValueError('the grammar should contain TRule objects') # <<<<<<<<<<<<<<
* _g.AddRule((<TRule> trule).rule[0])
*/
- __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_k_tuple_14);
__Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, ((PyObject *)__pyx_kp_s_13));
@@ -27618,12 +28098,16 @@ PyMODINIT_FUNC PyInit__cdec(void)
if (PyType_Ready(&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__Pyx_SetAttrString(__pyx_m, "TRule", (PyObject *)&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec_TRule = &__pyx_type_5_cdec_TRule;
- if (PyType_Ready(&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "Grammar", (PyObject *)&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_type_5_cdec_MRule.tp_base = __pyx_ptype_5_cdec_TRule;
+ if (PyType_Ready(&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "MRule", (PyObject *)&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec_MRule = &__pyx_type_5_cdec_MRule;
+ if (PyType_Ready(&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "Grammar", (PyObject *)&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec_Grammar = &__pyx_type_5_cdec_Grammar;
__pyx_type_5_cdec_TextGrammar.tp_base = __pyx_ptype_5_cdec_Grammar;
- if (PyType_Ready(&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "TextGrammar", (PyObject *)&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "TextGrammar", (PyObject *)&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec_TextGrammar = &__pyx_type_5_cdec_TextGrammar;
if (PyType_Ready(&__pyx_type_5_cdec_Hypergraph) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__Pyx_SetAttrString(__pyx_m, "Hypergraph", (PyObject *)&__pyx_type_5_cdec_Hypergraph) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -27678,7 +28162,7 @@ PyMODINIT_FUNC PyInit__cdec(void)
__pyx_ptype_5_cdec___pyx_scope_struct_5___str__ = &__pyx_type_5_cdec___pyx_scope_struct_5___str__;
if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_6_genexpr) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec___pyx_scope_struct_6_genexpr = &__pyx_type_5_cdec___pyx_scope_struct_6_genexpr;
- if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_7___iter__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_7___iter__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec___pyx_scope_struct_7___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_7___iter__;
if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_8_kbest) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec___pyx_scope_struct_8_kbest = &__pyx_type_5_cdec___pyx_scope_struct_8_kbest;
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