summaryrefslogtreecommitdiff
path: root/python/src/_cdec.cpp
diff options
context:
space:
mode:
authorVictor Chahuneau <vchahune@cs.cmu.edu>2012-07-27 22:25:15 -0400
committerVictor Chahuneau <vchahune@cs.cmu.edu>2012-07-27 22:25:15 -0400
commit9961abf8f756279ac6d839e0b3de2b0d83431965 (patch)
tree2defad3f49df2921ff68a48a07a9ca0693a1f0f7 /python/src/_cdec.cpp
parent733e1b1507d27d4f53055f740e8098f56215ab8f (diff)
[python] conversion from cdec.sa.Rule to cdec.TRule
+ remove configobj dependency + re-structure packages (no more top-level library) + "const" stuff + use __new__ instead of constructor for some objects
Diffstat (limited to 'python/src/_cdec.cpp')
-rw-r--r--python/src/_cdec.cpp5677
1 files changed, 3568 insertions, 2109 deletions
diff --git a/python/src/_cdec.cpp b/python/src/_cdec.cpp
index 44cd6568..20b86169 100644
--- a/python/src/_cdec.cpp
+++ b/python/src/_cdec.cpp
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.16 on Wed Jul 25 23:56:10 2012 */
+/* Generated by Cython 0.17.beta1 on Fri Jul 27 22:15:28 2012 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -47,12 +47,6 @@
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyCFunction_Call PyObject_Call
-#else
- #define __Pyx_PyCFunction_Call PyCFunction_Call
-#endif
-
#if PY_VERSION_HEX < 0x02050000
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
@@ -60,8 +54,11 @@
#define PY_FORMAT_SIZE_T ""
#define PyInt_FromSsize_t(z) PyInt_FromLong(z)
#define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o)
- #define PyNumber_Index(o) PyNumber_Int(o)
- #define PyIndex_Check(o) PyNumber_Check(o)
+ #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
+ (PyErr_Format(PyExc_TypeError, \
+ "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
+ (PyObject*)0))
+ #define PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && !PyComplex_Check(o))
#define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#define __PYX_BUILD_PY_SSIZE_T "i"
#else
@@ -130,14 +127,20 @@
#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_GET_LENGTH)
+#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
#define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
+ #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \
+ 0 : _PyUnicode_Ready((PyObject *)(op)))
+ #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
+ #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
#else
#define CYTHON_PEP393_ENABLED 0
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
+ #define __Pyx_PyUnicode_READY(op) (0)
+ #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
+
+ #define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif
#if PY_MAJOR_VERSION >= 3
@@ -270,6 +273,7 @@
#include <math.h>
#define __PYX_HAVE___cdec
#define __PYX_HAVE_API___cdec
+#include "string.h"
#include <string>
#include <vector>
#include <utility>
@@ -357,7 +361,11 @@ static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
+#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
+#else
+#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
+#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#ifdef __GNUC__
@@ -391,6 +399,8 @@ static const char *__pyx_f[] = {
"hypergraph.pxi",
"lattice.pxi",
"mteval.pxi",
+ "stringsource",
+ "cdec.sa._sa.pxd",
};
/*--- Type declarations ---*/
@@ -398,15 +408,15 @@ struct __pyx_obj_5_cdec_Scorer;
struct __pyx_obj_5_cdec_NTRef;
struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__;
struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr;
+struct __pyx_obj_4cdec_2sa_3_sa_Phrase;
struct __pyx_obj_5_cdec_Grammar;
struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__;
struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot;
struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase;
struct __pyx_obj_5_cdec_CandidateSet;
struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__;
-struct __pyx_obj_5_cdec_BaseTRule;
struct __pyx_obj_5_cdec_TRule;
-struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr;
+struct __pyx_obj_4cdec_2sa_3_sa_Rule;
struct __pyx_obj_5_cdec_SegmentEvaluator;
struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__;
struct __pyx_obj_5_cdec_Candidate;
@@ -420,7 +430,7 @@ struct __pyx_obj_5_cdec_Decoder;
struct __pyx_obj_5_cdec_HypergraphNode;
struct __pyx_obj_5_cdec_SparseVector;
struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__;
-struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__;
+struct __pyx_obj_5_cdec___pyx_scope_struct____iter__;
struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__;
struct __pyx_obj_5_cdec_DenseVector;
struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__;
@@ -430,11 +440,12 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest;
struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features;
struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__;
struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__;
+struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr;
struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees;
struct __pyx_obj_5_cdec_Hypergraph;
struct __pyx_obj_5_cdec_Lattice;
struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample;
-struct __pyx_obj_5_cdec___pyx_scope_struct____iter__;
+struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__;
struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config;
struct __pyx_obj_5_cdec_TextGrammar;
struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines;
@@ -443,13 +454,13 @@ struct __pyx_opt_args_5_cdec_as_str;
/* "_cdec.pyx":6
* cimport decoder
*
- * cdef char* as_str(data, error_msg='Cannot convert type %s to str'): # <<<<<<<<<<<<<<
+ * cdef char* as_str(data, char* error_msg='Cannot convert type %s to str'): # <<<<<<<<<<<<<<
* cdef bytes ret
* if isinstance(data, unicode):
*/
struct __pyx_opt_args_5_cdec_as_str {
int __pyx_n;
- PyObject *error_msg;
+ char *error_msg;
};
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":117
@@ -466,7 +477,7 @@ struct __pyx_obj_5_cdec_Scorer {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":18
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":20
* return '[%s]' % self.cat
*
* cdef class NTRef: # <<<<<<<<<<<<<<
@@ -509,8 +520,23 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":146
- * self.rule.get().ComputeArity()
+/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":1
+ * cdef class Phrase: # <<<<<<<<<<<<<<
+ * cdef int *syms
+ * cdef int n, *varpos, n_vars
+ */
+struct __pyx_obj_4cdec_2sa_3_sa_Phrase {
+ PyObject_HEAD
+ struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase *__pyx_vtab;
+ int *syms;
+ int n;
+ int *varpos;
+ int n_vars;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":169
+ * _phrase(self.f), _phrase(self.e), scores)
*
* cdef class Grammar: # <<<<<<<<<<<<<<
* cdef shared_ptr[grammar.Grammar]* grammar
@@ -539,7 +565,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ {
/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":57
- * del self.lattice
+ * yield self[i]
*
* def todot(self): # <<<<<<<<<<<<<<
* def lines():
@@ -551,8 +577,8 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":3
- * cimport grammar
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5
+ * import cdec.sa._sa as _sa
*
* def _phrase(phrase): # <<<<<<<<<<<<<<
* return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase)
@@ -595,45 +621,34 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":26
- * return '[%d]' % self.ref
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":50
+ * return TRule(lhs, f, e, scores, a)
*
- * cdef class BaseTRule: # <<<<<<<<<<<<<<
+ * cdef class TRule: # <<<<<<<<<<<<<<
* cdef shared_ptr[grammar.TRule]* rule
*
*/
-struct __pyx_obj_5_cdec_BaseTRule {
+struct __pyx_obj_5_cdec_TRule {
PyObject_HEAD
boost::shared_ptr<TRule> *rule;
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":135
- * _phrase(self.f), _phrase(self.e), scores)
+/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":7
+ * cdef public int chunklen(self, int k)
*
- * cdef class TRule(BaseTRule): # <<<<<<<<<<<<<<
- * def __cinit__(self, lhs, f, e, scores, a=None):
- * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule())
- */
-struct __pyx_obj_5_cdec_TRule {
- struct __pyx_obj_5_cdec_BaseTRule __pyx_base;
-};
-
-
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":4
- *
- * def _phrase(phrase):
- * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) # <<<<<<<<<<<<<<
- *
- * cdef class NT:
+ * cdef class Rule: # <<<<<<<<<<<<<<
+ * cdef public int lhs
+ * cdef readonly Phrase f, e
*/
-struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr {
+struct __pyx_obj_4cdec_2sa_3_sa_Rule {
PyObject_HEAD
- struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *__pyx_outer_scope;
- PyObject *__pyx_v_w;
- PyObject *__pyx_t_0;
- Py_ssize_t __pyx_t_1;
- PyObject *(*__pyx_t_2)(PyObject *);
+ int lhs;
+ struct __pyx_obj_4cdec_2sa_3_sa_Phrase *f;
+ struct __pyx_obj_4cdec_2sa_3_sa_Phrase *e;
+ float *cscores;
+ int n_scores;
+ PyObject *word_alignments;
};
@@ -672,7 +687,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ {
* return stats
*
* cdef class Candidate: # <<<<<<<<<<<<<<
- * cdef mteval.Candidate* candidate
+ * cdef mteval.const_Candidate* candidate
* cdef public float score
*/
struct __pyx_obj_5_cdec_Candidate {
@@ -682,7 +697,7 @@ struct __pyx_obj_5_cdec_Candidate {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":131
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":165
*
* def __str__(self):
* scores = ' '.join('%s=%s' % feat for feat in self.scores) # <<<<<<<<<<<<<<
@@ -699,7 +714,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":6
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":8
* return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase)
*
* cdef class NT: # <<<<<<<<<<<<<<
@@ -724,12 +739,12 @@ struct __pyx_obj_5_cdec_HypergraphEdge {
PyObject_HEAD
struct __pyx_vtabstruct_5_cdec_HypergraphEdge *__pyx_vtab;
Hypergraph *hg;
- const Hypergraph::Edge *edge;
- struct __pyx_obj_5_cdec_BaseTRule *trule;
+ Hypergraph::Edge *edge;
+ struct __pyx_obj_5_cdec_TRule *trule;
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":55
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":67
* self.vector.set_value(fid, value)
*
* def __iter__(self): # <<<<<<<<<<<<<<
@@ -762,7 +777,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":90
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":124
*
* property a:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -773,7 +788,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ {
PyObject_HEAD
std::vector<AlignmentPoint> *__pyx_v_a;
unsigned int __pyx_v_i;
- struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self;
+ struct __pyx_obj_5_cdec_TRule *__pyx_v_self;
size_t __pyx_t_0;
unsigned int __pyx_t_1;
};
@@ -804,11 +819,11 @@ struct __pyx_obj_5_cdec_HypergraphNode {
PyObject_HEAD
struct __pyx_vtabstruct_5_cdec_HypergraphNode *__pyx_vtab;
Hypergraph *hg;
- const Hypergraph::Node *node;
+ Hypergraph::Node *node;
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":36
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":45
* return sparse
*
* cdef class SparseVector: # <<<<<<<<<<<<<<
@@ -821,7 +836,7 @@ struct __pyx_obj_5_cdec_SparseVector {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":49
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":52
* return hypergraph.AsPLF(self.lattice[0], True).c_str()
*
* def __iter__(self): # <<<<<<<<<<<<<<
@@ -837,17 +852,17 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":113
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":31
+ * self.vector[0][fid] = value
*
- * property edges:
- * def __get__(self): # <<<<<<<<<<<<<<
- * cdef unsigned i
- * for i in range(self.hg.edges_.size()):
+ * def __iter__(self): # <<<<<<<<<<<<<<
+ * cdef unsigned fid
+ * for fid in range(1, self.vector.size()):
*/
-struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ {
+struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ {
PyObject_HEAD
- unsigned int __pyx_v_i;
- struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self;
+ unsigned int __pyx_v_fid;
+ struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self;
size_t __pyx_t_0;
unsigned int __pyx_t_1;
};
@@ -873,21 +888,22 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ {
* from cython.operator cimport preincrement as pinc
*
* cdef class DenseVector: # <<<<<<<<<<<<<<
- * cdef vector[weight_t]* vector # Not owned by DenseVector
- *
+ * cdef vector[weight_t]* vector
+ * cdef bint owned # if True, do not manage memory
*/
struct __pyx_obj_5_cdec_DenseVector {
PyObject_HEAD
std::vector<weight_t> *vector;
+ int owned;
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":152
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":175
* del self.grammar
*
* def __iter__(self): # <<<<<<<<<<<<<<
- * cdef grammar.GrammarIter* root = self.grammar.get().GetRoot()
- * cdef grammar.RuleBin* rbin = root.GetRules()
+ * cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot()
+ * cdef grammar.const_RuleBin* rbin = root.GetRules()
*/
struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ {
PyObject_HEAD
@@ -983,7 +999,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":130
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":164
* self.rule.get().lhs_ = -TDConvert(<char *>lhs.cat)
*
* def __str__(self): # <<<<<<<<<<<<<<
@@ -992,7 +1008,24 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ {
*/
struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ {
PyObject_HEAD
- struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self;
+ struct __pyx_obj_5_cdec_TRule *__pyx_v_self;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":6
+ *
+ * def _phrase(phrase):
+ * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) # <<<<<<<<<<<<<<
+ *
+ * cdef class NT:
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr {
+ PyObject_HEAD
+ struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *__pyx_outer_scope;
+ PyObject *__pyx_v_w;
+ PyObject *__pyx_t_0;
+ Py_ssize_t __pyx_t_1;
+ PyObject *(*__pyx_t_2)(PyObject *);
};
@@ -1064,17 +1097,17 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":22
- * self.vector[0][fid] = value
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":113
*
- * def __iter__(self): # <<<<<<<<<<<<<<
- * cdef unsigned fid
- * for fid in range(1, self.vector.size()):
+ * property edges:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * for i in range(self.hg.edges_.size()):
*/
-struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ {
+struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ {
PyObject_HEAD
- unsigned int __pyx_v_fid;
- struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self;
+ unsigned int __pyx_v_i;
+ struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self;
size_t __pyx_t_0;
unsigned int __pyx_t_1;
};
@@ -1103,7 +1136,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":169
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":192
* self.grammar.get().SetGrammarName(string(<char *>name))
*
* cdef class TextGrammar(Grammar): # <<<<<<<<<<<<<<
@@ -1139,6 +1172,19 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines {
+/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":1
+ * cdef class Phrase: # <<<<<<<<<<<<<<
+ * cdef int *syms
+ * cdef int n, *varpos, n_vars
+ */
+
+struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase {
+ int (*chunkpos)(struct __pyx_obj_4cdec_2sa_3_sa_Phrase *, int);
+ int (*chunklen)(struct __pyx_obj_4cdec_2sa_3_sa_Phrase *, int);
+};
+static struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase *__pyx_vtabptr_4cdec_2sa_3_sa_Phrase;
+
+
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":193
* raise NotImplemented('comparison not implemented for HypergraphEdge')
*
@@ -1226,9 +1272,19 @@ static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyOb
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
+static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
+ Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
+
+static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/
+
static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
const char *name, int exact); /*proto*/
+static CYTHON_INLINE PyObject* __Pyx_tp_new(PyObject* type_obj) {
+ return (PyObject*) (((PyTypeObject*)(type_obj))->tp_new(
+ (PyTypeObject*)(type_obj), __pyx_empty_tuple, NULL));
+}
+
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);
@@ -1239,16 +1295,28 @@ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
const char* function_name); /*proto*/
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
+ PyListObject* L = (PyListObject*) list;
+ Py_ssize_t len = Py_SIZE(list);
+ if (likely(L->allocated > len)) {
+ Py_INCREF(x);
+ PyList_SET_ITEM(list, len, x);
+ Py_SIZE(list) = len+1;
+ return 0;
+ }
+ return PyList_Append(list, x);
+}
+#else
+#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
+#endif
static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
if (likely(PyList_CheckExact(L))) {
- if (PyList_Append(L, x) < 0) return NULL;
+ if (unlikely(PyList_Append(L, x) < 0)) return NULL;
Py_INCREF(Py_None);
return Py_None; /* this is just to have an accurate signature */
- }
- else {
+ } else {
PyObject *r, *m;
m = __Pyx_GetAttrString(L, "append");
if (!m) return NULL;
@@ -1269,42 +1337,47 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j
__Pyx_GetItemInt_List_Fast(o, i) : \
__Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
- if (likely(o != Py_None)) {
- if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
- PyObject *r = PyList_GET_ITEM(o, i);
- Py_INCREF(r);
- return r;
- }
- else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
- PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
- Py_INCREF(r);
- return r;
- }
+#if CYTHON_COMPILING_IN_CPYTHON
+ if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+ PyObject *r = PyList_GET_ITEM(o, i);
+ Py_INCREF(r);
+ return r;
+ }
+ else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
+ PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
+ Py_INCREF(r);
+ return r;
}
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+#else
+ return PySequence_GetItem(o, i);
+#endif
}
#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
__Pyx_GetItemInt_Tuple_Fast(o, i) : \
__Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
- if (likely(o != Py_None)) {
- if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, i);
- Py_INCREF(r);
- return r;
- }
- else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
- PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
- Py_INCREF(r);
- return r;
- }
+#if CYTHON_COMPILING_IN_CPYTHON
+ if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
+ PyObject *r = PyTuple_GET_ITEM(o, i);
+ Py_INCREF(r);
+ return r;
+ }
+ else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
+ PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
+ Py_INCREF(r);
+ return r;
}
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+#else
+ return PySequence_GetItem(o, i);
+#endif
}
#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
__Pyx_GetItemInt_Fast(o, i) : \
__Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
+#if CYTHON_COMPILING_IN_CPYTHON
if (PyList_CheckExact(o)) {
Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
@@ -1320,19 +1393,30 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i)
Py_INCREF(r);
return r;
}
- }
- else if (likely(i >= 0)) {
+ } else { /* inlined PySequence_GetItem() */
PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
if (likely(m && m->sq_item)) {
+ if (unlikely(i < 0) && likely(m->sq_length)) {
+ Py_ssize_t l = m->sq_length(o);
+ if (unlikely(l < 0)) return NULL;
+ i += l;
+ }
return m->sq_item(o, i);
}
}
+#else
+ if (PySequence_Check(o)) {
+ return PySequence_GetItem(o, i);
+ }
+#endif
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}
+static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
+
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
+static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/
@@ -1343,26 +1427,72 @@ static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
}
-#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL);
+#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *); /*proto*/
-static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/
-
static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */
+#if CYTHON_COMPILING_IN_PYPY
+#define __Pyx_PyObject_AsDouble(obj) \
+(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) : \
+ likely(PyInt_CheckExact(obj)) ? \
+ PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
+#else
#define __Pyx_PyObject_AsDouble(obj) \
((likely(PyFloat_CheckExact(obj))) ? \
PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
+#endif
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/
+
static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/
static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
PyObject *modname); /*proto*/
+#ifndef __Pyx_CppExn2PyErr
+#include <new>
+#include <typeinfo>
+#include <stdexcept>
+#include <ios>
+static void __Pyx_CppExn2PyErr() {
+ try {
+ if (PyErr_Occurred())
+ ; // let the latest Python exn pass through and ignore the current one
+ else
+ throw;
+ } catch (const std::bad_alloc& exn) {
+ PyErr_SetString(PyExc_MemoryError, exn.what());
+ } catch (const std::bad_cast& exn) {
+ PyErr_SetString(PyExc_TypeError, exn.what());
+ } catch (const std::domain_error& exn) {
+ PyErr_SetString(PyExc_ValueError, exn.what());
+ } catch (const std::invalid_argument& exn) {
+ PyErr_SetString(PyExc_ValueError, exn.what());
+ } catch (const std::ios_base::failure& exn) {
+ PyErr_SetString(PyExc_IOError, exn.what());
+ } catch (const std::out_of_range& exn) {
+ PyErr_SetString(PyExc_IndexError, exn.what());
+ } catch (const std::overflow_error& exn) {
+ PyErr_SetString(PyExc_OverflowError, exn.what());
+ } catch (const std::range_error& exn) {
+ PyErr_SetString(PyExc_ArithmeticError, exn.what());
+ } catch (const std::underflow_error& exn) {
+ PyErr_SetString(PyExc_ArithmeticError, exn.what());
+ } catch (const std::exception& exn) {
+ PyErr_SetString(PyExc_RuntimeError, exn.what());
+ }
+ catch (...)
+ {
+ PyErr_SetString(PyExc_RuntimeError, "Unknown exception");
+ }
+}
+#endif
+
static CYTHON_INLINE WordID __Pyx_PyInt_from_py_WordID(PyObject *);
static PyObject* __Pyx_Globals(void); /*proto*/
@@ -1460,6 +1590,7 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value,
#define __Pyx_Generator_USED
#include <structmember.h>
+#include <frameobject.h>
typedef PyObject *(*__pyx_generator_body_t)(PyObject *, PyObject *);
typedef struct {
PyObject_HEAD
@@ -1472,15 +1603,38 @@ typedef struct {
PyObject *exc_traceback;
PyObject *gi_weakreflist;
PyObject *classobj;
+ PyObject *yieldfrom;
} __pyx_GeneratorObject;
static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
PyObject *closure);
static int __pyx_Generator_init(void);
+static int __Pyx_Generator_clear(PyObject* self);
+#if 1 || PY_VERSION_HEX < 0x030300B0
+static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue);
+#else
+#define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue)
+#endif
static int __Pyx_check_binary_version(void);
static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
+#if !defined(__Pyx_PyIdentifier_FromString)
+#if PY_MAJOR_VERSION < 3
+ #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
+#else
+ #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
+#endif
+#endif
+
+static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/
+
+static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
+
+static void* __Pyx_GetVtable(PyObject *dict); /*proto*/
+
+static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/
+
typedef struct {
int code_line;
PyCodeObject* code_object;
@@ -1501,6 +1655,8 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line,
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+/* Module declarations from 'libc.string' */
+
/* Module declarations from 'libcpp.string' */
/* Module declarations from 'libcpp.vector' */
@@ -1519,6 +1675,14 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from 'decoder' */
+/* Module declarations from 'cdec.sa._sa' */
+static PyTypeObject *__pyx_ptype_4cdec_2sa_3_sa_Phrase = 0;
+static PyTypeObject *__pyx_ptype_4cdec_2sa_3_sa_Rule = 0;
+static char *(*__pyx_f_4cdec_2sa_3_sa_sym_tostring)(int); /*proto*/
+static char *(*__pyx_f_4cdec_2sa_3_sa_sym_tocat)(int); /*proto*/
+static int (*__pyx_f_4cdec_2sa_3_sa_sym_isvar)(int); /*proto*/
+static int (*__pyx_f_4cdec_2sa_3_sa_sym_getindex)(int); /*proto*/
+
/* Module declarations from 'kbest' */
/* Module declarations from 'mteval' */
@@ -1528,7 +1692,6 @@ static PyTypeObject *__pyx_ptype_5_cdec_DenseVector = 0;
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_BaseTRule = 0;
static PyTypeObject *__pyx_ptype_5_cdec_TRule = 0;
static PyTypeObject *__pyx_ptype_5_cdec_Grammar = 0;
static PyTypeObject *__pyx_ptype_5_cdec_TextGrammar = 0;
@@ -1569,9 +1732,11 @@ static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_22__make_config = 0;
static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_23___cinit__ = 0;
static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_24_genexpr = 0;
static char *__pyx_f_5_cdec_as_str(PyObject *, struct __pyx_opt_args_5_cdec_as_str *__pyx_optional_args); /*proto*/
+static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_obj_4cdec_2sa_3_sa_Rule *); /*proto*/
static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject *, PyObject *); /*proto*/
static float __pyx_f_5_cdec__compute_score(void *, SufficientStats *); /*proto*/
static void __pyx_f_5_cdec__compute_sufficient_stats(void *, std::string *, std::vector<std::string> *, SufficientStats *); /*proto*/
+static PyObject *__pyx_convert_string_to_py_(const std::string &); /*proto*/
#define __Pyx_MODULE_NAME "_cdec"
int __pyx_module_is_main__cdec = 0;
@@ -1586,33 +1751,36 @@ static PyObject *__pyx_builtin_eval;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_open;
-static Py_ssize_t __pyx_pf_5_cdec_11DenseVector___len__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5_cdec_11DenseVector_2__getitem__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, char *__pyx_v_fname); /* proto */
-static int __pyx_pf_5_cdec_11DenseVector_4__setitem__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, char *__pyx_v_fname, float __pyx_v_value); /* proto */
-static PyObject *__pyx_pf_5_cdec_11DenseVector_6__iter__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5_cdec_11DenseVector_9dot(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other); /* proto */
-static PyObject *__pyx_pf_5_cdec_11DenseVector_11tosparse(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self); /* proto */
-static void __pyx_pf_5_cdec_12SparseVector___dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5_cdec_12SparseVector_2copy(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5_cdec_12SparseVector_4__getitem__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname); /* proto */
-static int __pyx_pf_5_cdec_12SparseVector_6__setitem__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname, float __pyx_v_value); /* proto */
-static PyObject *__pyx_pf_5_cdec_12SparseVector_8__iter__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5_cdec_12SparseVector_11dot(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
-static PyObject *__pyx_pf_5_cdec_12SparseVector_13__richcmp__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y, int __pyx_v_op); /* proto */
-static Py_ssize_t __pyx_pf_5_cdec_12SparseVector_15__len__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
-static int __pyx_pf_5_cdec_12SparseVector_17__contains__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname); /* proto */
-static PyObject *__pyx_pf_5_cdec_12SparseVector_19__neg__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5_cdec_12SparseVector_21__iadd__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other); /* proto */
-static PyObject *__pyx_pf_5_cdec_12SparseVector_23__isub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other); /* proto */
-static PyObject *__pyx_pf_5_cdec_12SparseVector_25__imul__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar); /* proto */
+static int __pyx_pf_5_cdec_11DenseVector___init__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self); /* proto */
+static void __pyx_pf_5_cdec_11DenseVector_2__dealloc__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self); /* proto */
+static Py_ssize_t __pyx_pf_5_cdec_11DenseVector_4__len__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_11DenseVector_6__getitem__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, char *__pyx_v_fname); /* proto */
+static int __pyx_pf_5_cdec_11DenseVector_8__setitem__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, char *__pyx_v_fname, float __pyx_v_value); /* proto */
+static PyObject *__pyx_pf_5_cdec_11DenseVector_10__iter__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_11DenseVector_13dot(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other); /* proto */
+static PyObject *__pyx_pf_5_cdec_11DenseVector_15tosparse(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_12SparseVector___init__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
+static void __pyx_pf_5_cdec_12SparseVector_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_4copy(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_6__getitem__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname); /* proto */
+static int __pyx_pf_5_cdec_12SparseVector_8__setitem__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname, float __pyx_v_value); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_10__iter__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y, int __pyx_v_op); /* proto */
+static Py_ssize_t __pyx_pf_5_cdec_12SparseVector_17__len__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_12SparseVector_19__contains__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_21__neg__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_23__iadd__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_25__isub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_27__imul__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar); /* proto */
#if PY_MAJOR_VERSION < 3
-static PyObject *__pyx_pf_5_cdec_12SparseVector_27__idiv__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_29__idiv__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar); /* proto */
#endif
-static PyObject *__pyx_pf_5_cdec_12SparseVector_29__add__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y); /* proto */
-static PyObject *__pyx_pf_5_cdec_12SparseVector_31__sub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y); /* proto */
-static PyObject *__pyx_pf_5_cdec_12SparseVector_33__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_31__add__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_33__sub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_35__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
#if PY_MAJOR_VERSION < 3
-static PyObject *__pyx_pf_5_cdec_12SparseVector_35__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_37__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
#endif
static PyObject *__pyx_pf_5_cdec_7_phrase_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5_cdec__phrase(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_phrase); /* proto */
@@ -1626,21 +1794,21 @@ static int __pyx_pf_5_cdec_5NTRef___init__(struct __pyx_obj_5_cdec_NTRef *__pyx_
static PyObject *__pyx_pf_5_cdec_5NTRef_2__str__(struct __pyx_obj_5_cdec_NTRef *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5_cdec_5NTRef_3ref___get__(struct __pyx_obj_5_cdec_NTRef *__pyx_v_self); /* proto */
static int __pyx_pf_5_cdec_5NTRef_3ref_2__set__(struct __pyx_obj_5_cdec_NTRef *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
-static void __pyx_pf_5_cdec_9BaseTRule___dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_5arity___get__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_1f___get__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self); /* proto */
-static int __pyx_pf_5_cdec_9BaseTRule_1f_2__set__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_1e___get__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self); /* proto */
-static int __pyx_pf_5_cdec_9BaseTRule_1e_2__set__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self, PyObject *__pyx_v_e); /* proto */
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_1a___get__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self); /* proto */
-static int __pyx_pf_5_cdec_9BaseTRule_1a_3__set__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self, PyObject *__pyx_v_a); /* proto */
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_6scores___get__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self); /* proto */
-static int __pyx_pf_5_cdec_9BaseTRule_6scores_2__set__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self, PyObject *__pyx_v_scores); /* proto */
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_3lhs___get__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self); /* proto */
-static int __pyx_pf_5_cdec_9BaseTRule_3lhs_2__set__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self, PyObject *__pyx_v_lhs); /* proto */
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_7__str___genexpr(PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_2__str__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self); /* proto */
-static int __pyx_pf_5_cdec_5TRule___cinit__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_f, PyObject *__pyx_v_e, PyObject *__pyx_v_scores, PyObject *__pyx_v_a); /* proto */
+static int __pyx_pf_5_cdec_5TRule___init__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_f, PyObject *__pyx_v_e, PyObject *__pyx_v_scores, PyObject *__pyx_v_a); /* proto */
+static void __pyx_pf_5_cdec_5TRule_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_5TRule_5arity___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
+static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_e); /* proto */
+static PyObject *__pyx_pf_5_cdec_5TRule_1a___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_a); /* proto */
+static PyObject *__pyx_pf_5_cdec_5TRule_6scores___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_scores); /* proto */
+static PyObject *__pyx_pf_5_cdec_5TRule_3lhs___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+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 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 */
@@ -1680,12 +1848,12 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_4span___get__(struct __pyx_obj
static PyObject *__pyx_pf_5_cdec_14HypergraphNode_3cat___get__(struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_x, struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_y, int __pyx_v_op); /* proto */
static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */
-static PyObject *__pyx_pf_5_cdec_7Lattice_2__getitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index); /* proto */
-static int __pyx_pf_5_cdec_7Lattice_4__setitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index, PyObject *__pyx_v_arcs); /* proto */
-static Py_ssize_t __pyx_pf_5_cdec_7Lattice_6__len__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5_cdec_7Lattice_8__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5_cdec_7Lattice_10__iter__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
-static void __pyx_pf_5_cdec_7Lattice_13__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
+static void __pyx_pf_5_cdec_7Lattice_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index); /* proto */
+static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index, PyObject *__pyx_v_arcs); /* proto */
+static Py_ssize_t __pyx_pf_5_cdec_7Lattice_8__len__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_7Lattice_10__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_7Lattice_12__iter__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5_cdec_7Lattice_5todot_lines(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_5_cdec_7Lattice_15todot(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5_cdec_9Candidate_5words___get__(struct __pyx_obj_5_cdec_Candidate *__pyx_v_self); /* proto */
@@ -1760,8 +1928,10 @@ static char __pyx_k_48[] = "formalism \"%s\" unknown";
static char __pyx_k_49[] = "cannot initialize weights with %s";
static char __pyx_k_50[] = "#";
static char __pyx_k_53[] = "Cannot translate input type %s";
-static char __pyx_k_56[] = "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi";
-static char __pyx_k_62[] = "/Users/vchahun/Sandbox/cdec/python/src/_cdec.pyx";
+static char __pyx_k_54[] = "cdec.sa._sa";
+static char __pyx_k_55[] = "*";
+static char __pyx_k_58[] = "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi";
+static char __pyx_k_64[] = "/Users/vchahun/Sandbox/cdec/python/src/_cdec.pyx";
static char __pyx_k__a[] = "a";
static char __pyx_k__e[] = "e";
static char __pyx_k__f[] = "f";
@@ -1770,6 +1940,7 @@ static char __pyx_k__k[] = "k";
static char __pyx_k__pb[] = "pb";
static char __pyx_k__CER[] = "CER";
static char __pyx_k__TER[] = "TER";
+static char __pyx_k___sa[] = "_sa";
static char __pyx_k__cat[] = "cat";
static char __pyx_k__dot[] = "dot";
static char __pyx_k__fst[] = "fst";
@@ -1805,6 +1976,7 @@ static char __pyx_k__value[] = "value";
static char __pyx_k__config[] = "config";
static char __pyx_k__csplit[] = "csplit";
static char __pyx_k__encode[] = "encode";
+static char __pyx_k__format[] = "format";
static char __pyx_k__phrase[] = "phrase";
static char __pyx_k__scores[] = "scores";
static char __pyx_k__tagger[] = "tagger";
@@ -1840,10 +2012,10 @@ static char __pyx_k__config_str[] = "config_str";
static char __pyx_k__hypergraph[] = "hypergraph";
static char __pyx_k__startswith[] = "startswith";
static char __pyx_k__ParseFailed[] = "ParseFailed";
+static char __pyx_k__PhraseModel_[] = "PhraseModel_";
static char __pyx_k___make_config[] = "_make_config";
static char __pyx_k__InvalidConfig[] = "InvalidConfig";
static char __pyx_k__NotImplemented[] = "NotImplemented";
-static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_10;
static PyObject *__pyx_kp_s_11;
static PyObject *__pyx_kp_s_12;
@@ -1874,8 +2046,10 @@ static PyObject *__pyx_kp_s_48;
static PyObject *__pyx_kp_s_49;
static PyObject *__pyx_kp_s_50;
static PyObject *__pyx_kp_s_53;
-static PyObject *__pyx_kp_s_56;
-static PyObject *__pyx_kp_s_62;
+static PyObject *__pyx_n_s_54;
+static PyObject *__pyx_n_s_55;
+static PyObject *__pyx_kp_s_58;
+static PyObject *__pyx_kp_s_64;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_kp_s_8;
static PyObject *__pyx_kp_s_9;
@@ -1888,6 +2062,7 @@ static PyObject *__pyx_n_s__InvalidConfig;
static PyObject *__pyx_n_s__KeyError;
static PyObject *__pyx_n_s__NotImplemented;
static PyObject *__pyx_n_s__ParseFailed;
+static PyObject *__pyx_n_s__PhraseModel_;
static PyObject *__pyx_n_s__TER;
static PyObject *__pyx_n_s__TypeError;
static PyObject *__pyx_n_s__ValueError;
@@ -1900,6 +2075,7 @@ static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___cdec;
static PyObject *__pyx_n_s___make_config;
static PyObject *__pyx_n_s___phrase;
+static PyObject *__pyx_n_s___sa;
static PyObject *__pyx_n_s__a;
static PyObject *__pyx_n_s__beam_alpha;
static PyObject *__pyx_n_s__cat;
@@ -1918,6 +2094,7 @@ static PyObject *__pyx_n_s__evaluate;
static PyObject *__pyx_n_s__evaluator;
static PyObject *__pyx_n_s__f;
static PyObject *__pyx_n_s__formalism;
+static PyObject *__pyx_n_s__format;
static PyObject *__pyx_n_s__fst;
static PyObject *__pyx_n_s__genexpr;
static PyObject *__pyx_n_s__get;
@@ -1962,6 +2139,7 @@ static PyObject *__pyx_n_s__value;
static PyObject *__pyx_n_s__weight;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
+static PyObject *__pyx_int_65536;
static PyObject *__pyx_k_tuple_2;
static PyObject *__pyx_k_tuple_5;
static PyObject *__pyx_k_tuple_6;
@@ -1980,32 +2158,33 @@ static PyObject *__pyx_k_tuple_44;
static PyObject *__pyx_k_tuple_47;
static PyObject *__pyx_k_tuple_51;
static PyObject *__pyx_k_tuple_52;
-static PyObject *__pyx_k_tuple_54;
-static PyObject *__pyx_k_tuple_57;
-static PyObject *__pyx_k_tuple_58;
+static PyObject *__pyx_k_tuple_56;
static PyObject *__pyx_k_tuple_59;
static PyObject *__pyx_k_tuple_60;
+static PyObject *__pyx_k_tuple_61;
+static PyObject *__pyx_k_tuple_62;
static PyObject *__pyx_k_codeobj_37;
-static PyObject *__pyx_k_codeobj_55;
-static PyObject *__pyx_k_codeobj_61;
+static PyObject *__pyx_k_codeobj_57;
+static PyObject *__pyx_k_codeobj_63;
/* "_cdec.pyx":6
* cimport decoder
*
- * cdef char* as_str(data, error_msg='Cannot convert type %s to str'): # <<<<<<<<<<<<<<
+ * cdef char* as_str(data, char* error_msg='Cannot convert type %s to str'): # <<<<<<<<<<<<<<
* cdef bytes ret
* if isinstance(data, unicode):
*/
static char *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_data, struct __pyx_opt_args_5_cdec_as_str *__pyx_optional_args) {
- PyObject *__pyx_v_error_msg = ((PyObject *)__pyx_kp_s_1);
+ char *__pyx_v_error_msg = ((char *)__pyx_k_1);
PyObject *__pyx_v_ret = 0;
char *__pyx_r;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
- char *__pyx_t_4;
+ PyObject *__pyx_t_4 = NULL;
+ char *__pyx_t_5;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
@@ -2017,7 +2196,7 @@ static char *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_data, struct __pyx_opt_args
}
/* "_cdec.pyx":8
- * cdef char* as_str(data, error_msg='Cannot convert type %s to str'):
+ * cdef char* as_str(data, char* error_msg='Cannot convert type %s to str'):
* cdef bytes ret
* if isinstance(data, unicode): # <<<<<<<<<<<<<<
* ret = data.encode('utf8')
@@ -2065,7 +2244,7 @@ static char *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_data, struct __pyx_opt_args
* elif isinstance(data, str):
* ret = data # <<<<<<<<<<<<<<
* else:
- * raise TypeError(error_msg % type(data))
+ * raise TypeError(error_msg.format(type(data)))
*/
if (!(likely(PyBytes_CheckExact(__pyx_v_data))||((__pyx_v_data) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_data)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_INCREF(__pyx_v_data);
@@ -2077,35 +2256,47 @@ static char *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_data, struct __pyx_opt_args
/* "_cdec.pyx":13
* ret = data
* else:
- * raise TypeError(error_msg % type(data)) # <<<<<<<<<<<<<<
+ * raise TypeError(error_msg.format(type(data))) # <<<<<<<<<<<<<<
* return ret
*
*/
- __pyx_t_3 = PyNumber_Remainder(__pyx_v_error_msg, ((PyObject *)Py_TYPE(__pyx_v_data))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyBytes_FromString(__pyx_v_error_msg); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+ __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_t_3), __pyx_n_s__format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_3);
- __pyx_t_3 = 0;
- __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_data)));
+ PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(__pyx_v_data)));
+ __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_data)));
+ __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
+ __Pyx_GIVEREF(__pyx_t_4);
+ __pyx_t_4 = 0;
+ __pyx_t_4 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_L3:;
/* "_cdec.pyx":14
* else:
- * raise TypeError(error_msg % type(data))
+ * raise TypeError(error_msg.format(type(data)))
* return ret # <<<<<<<<<<<<<<
*
* include "vectors.pxi"
*/
- __pyx_t_4 = PyBytes_AsString(((PyObject *)__pyx_v_ret)); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_t_4;
+ __pyx_t_5 = PyBytes_AsString(((PyObject *)__pyx_v_ret)); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_t_5;
goto __pyx_L0;
__pyx_r = 0;
@@ -2113,6 +2304,7 @@ static char *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_data, struct __pyx_opt_args
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
__Pyx_WriteUnraisable("_cdec.as_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
@@ -2122,30 +2314,127 @@ static char *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_data, struct __pyx_opt_args
}
/* Python wrapper */
-static Py_ssize_t __pyx_pw_5_cdec_11DenseVector_1__len__(PyObject *__pyx_v_self); /*proto*/
-static Py_ssize_t __pyx_pw_5_cdec_11DenseVector_1__len__(PyObject *__pyx_v_self) {
+static int __pyx_pw_5_cdec_11DenseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5_cdec_11DenseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+ if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
+ __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
+ if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
+ __pyx_r = __pyx_pf_5_cdec_11DenseVector___init__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":7
+ * cdef bint owned # if True, do not manage memory
+ *
+ * def __init__(self): # <<<<<<<<<<<<<<
+ * self.vector = new vector[weight_t]()
+ * self.owned = False
+ */
+
+static int __pyx_pf_5_cdec_11DenseVector___init__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__init__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":8
+ *
+ * def __init__(self):
+ * self.vector = new vector[weight_t]() # <<<<<<<<<<<<<<
+ * self.owned = False
+ *
+ */
+ __pyx_v_self->vector = new std::vector<weight_t>();
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":9
+ * def __init__(self):
+ * self.vector = new vector[weight_t]()
+ * self.owned = False # <<<<<<<<<<<<<<
+ *
+ * def __dealloc__(self):
+ */
+ __pyx_v_self->owned = 0;
+
+ __pyx_r = 0;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static void __pyx_pw_5_cdec_11DenseVector_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_5_cdec_11DenseVector_3__dealloc__(PyObject *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+ __pyx_pf_5_cdec_11DenseVector_2__dealloc__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":11
+ * self.owned = False
+ *
+ * def __dealloc__(self): # <<<<<<<<<<<<<<
+ * if not self.owned:
+ * del self.vector
+ */
+
+static void __pyx_pf_5_cdec_11DenseVector_2__dealloc__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ int __pyx_t_1;
+ __Pyx_RefNannySetupContext("__dealloc__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":12
+ *
+ * def __dealloc__(self):
+ * if not self.owned: # <<<<<<<<<<<<<<
+ * del self.vector
+ *
+ */
+ __pyx_t_1 = (!__pyx_v_self->owned);
+ if (__pyx_t_1) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":13
+ * def __dealloc__(self):
+ * if not self.owned:
+ * del self.vector # <<<<<<<<<<<<<<
+ *
+ * def __len__(self):
+ */
+ delete __pyx_v_self->vector;
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ __Pyx_RefNannyFinishContext();
+}
+
+/* Python wrapper */
+static Py_ssize_t __pyx_pw_5_cdec_11DenseVector_5__len__(PyObject *__pyx_v_self); /*proto*/
+static Py_ssize_t __pyx_pw_5_cdec_11DenseVector_5__len__(PyObject *__pyx_v_self) {
Py_ssize_t __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_11DenseVector___len__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_11DenseVector_4__len__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":6
- * cdef vector[weight_t]* vector # Not owned by DenseVector
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":15
+ * del self.vector
*
* def __len__(self): # <<<<<<<<<<<<<<
* return self.vector.size()
*
*/
-static Py_ssize_t __pyx_pf_5_cdec_11DenseVector___len__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) {
+static Py_ssize_t __pyx_pf_5_cdec_11DenseVector_4__len__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) {
Py_ssize_t __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__len__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":7
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":16
*
* def __len__(self):
* return self.vector.size() # <<<<<<<<<<<<<<
@@ -2162,14 +2451,14 @@ static Py_ssize_t __pyx_pf_5_cdec_11DenseVector___len__(struct __pyx_obj_5_cdec_
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_11DenseVector_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname); /*proto*/
-static PyObject *__pyx_pw_5_cdec_11DenseVector_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname) {
+static PyObject *__pyx_pw_5_cdec_11DenseVector_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname); /*proto*/
+static PyObject *__pyx_pw_5_cdec_11DenseVector_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname) {
char *__pyx_v_fname;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
assert(__pyx_arg_fname); {
- __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
@@ -2177,12 +2466,12 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_3__getitem__(PyObject *__pyx_v_se
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5_cdec_11DenseVector_2__getitem__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self), ((char *)__pyx_v_fname));
+ __pyx_r = __pyx_pf_5_cdec_11DenseVector_6__getitem__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self), ((char *)__pyx_v_fname));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":9
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":18
* return self.vector.size()
*
* def __getitem__(self, char* fname): # <<<<<<<<<<<<<<
@@ -2190,7 +2479,7 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_3__getitem__(PyObject *__pyx_v_se
* if 0 <= fid < self.vector.size():
*/
-static PyObject *__pyx_pf_5_cdec_11DenseVector_2__getitem__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, char *__pyx_v_fname) {
+static PyObject *__pyx_pf_5_cdec_11DenseVector_6__getitem__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, char *__pyx_v_fname) {
int __pyx_v_fid;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@@ -2202,7 +2491,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_2__getitem__(struct __pyx_obj_5_c
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__getitem__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":10
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":19
*
* def __getitem__(self, char* fname):
* cdef int fid = FDConvert(fname) # <<<<<<<<<<<<<<
@@ -2211,7 +2500,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_2__getitem__(struct __pyx_obj_5_c
*/
__pyx_v_fid = FD::Convert(__pyx_v_fname);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":11
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":20
* def __getitem__(self, char* fname):
* cdef int fid = FDConvert(fname)
* if 0 <= fid < self.vector.size(): # <<<<<<<<<<<<<<
@@ -2224,7 +2513,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_2__getitem__(struct __pyx_obj_5_c
}
if (__pyx_t_1) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":12
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":21
* cdef int fid = FDConvert(fname)
* if 0 <= fid < self.vector.size():
* return self.vector[0][fid] # <<<<<<<<<<<<<<
@@ -2232,7 +2521,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_2__getitem__(struct __pyx_obj_5_c
*
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = PyFloat_FromDouble(((__pyx_v_self->vector[0])[__pyx_v_fid])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyFloat_FromDouble(((__pyx_v_self->vector[0])[__pyx_v_fid])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
@@ -2241,26 +2530,26 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_2__getitem__(struct __pyx_obj_5_c
}
__pyx_L3:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":13
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":22
* if 0 <= fid < self.vector.size():
* return self.vector[0][fid]
* raise KeyError(fname) # <<<<<<<<<<<<<<
*
* def __setitem__(self, char* fname, float value):
*/
- __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_2));
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
__Pyx_GIVEREF(((PyObject *)__pyx_t_2));
__pyx_t_2 = 0;
- __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
__Pyx_Raise(__pyx_t_2, 0, 0, 0);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- {__pyx_filename = __pyx_f[1]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
@@ -2276,18 +2565,18 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_2__getitem__(struct __pyx_obj_5_c
}
/* Python wrapper */
-static int __pyx_pw_5_cdec_11DenseVector_5__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname, PyObject *__pyx_arg_value); /*proto*/
-static int __pyx_pw_5_cdec_11DenseVector_5__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname, PyObject *__pyx_arg_value) {
+static int __pyx_pw_5_cdec_11DenseVector_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname, PyObject *__pyx_arg_value); /*proto*/
+static int __pyx_pw_5_cdec_11DenseVector_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname, PyObject *__pyx_arg_value) {
char *__pyx_v_fname;
float __pyx_v_value;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
assert(__pyx_arg_fname); {
- __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
assert(__pyx_arg_value); {
- __pyx_v_value = __pyx_PyFloat_AsFloat(__pyx_arg_value); if (unlikely((__pyx_v_value == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_value = __pyx_PyFloat_AsFloat(__pyx_arg_value); if (unlikely((__pyx_v_value == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
@@ -2295,12 +2584,12 @@ static int __pyx_pw_5_cdec_11DenseVector_5__setitem__(PyObject *__pyx_v_self, Py
__Pyx_RefNannyFinishContext();
return -1;
__pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5_cdec_11DenseVector_4__setitem__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self), ((char *)__pyx_v_fname), ((float)__pyx_v_value));
+ __pyx_r = __pyx_pf_5_cdec_11DenseVector_8__setitem__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self), ((char *)__pyx_v_fname), ((float)__pyx_v_value));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":15
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":24
* raise KeyError(fname)
*
* def __setitem__(self, char* fname, float value): # <<<<<<<<<<<<<<
@@ -2308,7 +2597,7 @@ static int __pyx_pw_5_cdec_11DenseVector_5__setitem__(PyObject *__pyx_v_self, Py
* if fid < 0: raise KeyError(fname)
*/
-static int __pyx_pf_5_cdec_11DenseVector_4__setitem__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, char *__pyx_v_fname, float __pyx_v_value) {
+static int __pyx_pf_5_cdec_11DenseVector_8__setitem__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, char *__pyx_v_fname, float __pyx_v_value) {
int __pyx_v_fid;
int __pyx_r;
__Pyx_RefNannyDeclarations
@@ -2320,7 +2609,7 @@ static int __pyx_pf_5_cdec_11DenseVector_4__setitem__(struct __pyx_obj_5_cdec_De
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setitem__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":16
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":25
*
* def __setitem__(self, char* fname, float value):
* cdef int fid = FDConvert(<char *>fname) # <<<<<<<<<<<<<<
@@ -2329,7 +2618,7 @@ static int __pyx_pf_5_cdec_11DenseVector_4__setitem__(struct __pyx_obj_5_cdec_De
*/
__pyx_v_fid = FD::Convert(((char *)__pyx_v_fname));
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":17
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":26
* def __setitem__(self, char* fname, float value):
* cdef int fid = FDConvert(<char *>fname)
* if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<<
@@ -2338,24 +2627,24 @@ static int __pyx_pf_5_cdec_11DenseVector_4__setitem__(struct __pyx_obj_5_cdec_De
*/
__pyx_t_1 = (__pyx_v_fid < 0);
if (__pyx_t_1) {
- __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_2));
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
__Pyx_GIVEREF(((PyObject *)__pyx_t_2));
__pyx_t_2 = 0;
- __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
__Pyx_Raise(__pyx_t_2, 0, 0, 0);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- {__pyx_filename = __pyx_f[1]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":18
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":27
* cdef int fid = FDConvert(<char *>fname)
* if fid < 0: raise KeyError(fname)
* if self.vector.size() <= fid: # <<<<<<<<<<<<<<
@@ -2365,7 +2654,7 @@ static int __pyx_pf_5_cdec_11DenseVector_4__setitem__(struct __pyx_obj_5_cdec_De
__pyx_t_1 = (__pyx_v_self->vector->size() <= __pyx_v_fid);
if (__pyx_t_1) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":19
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":28
* if fid < 0: raise KeyError(fname)
* if self.vector.size() <= fid:
* self.vector.resize(fid + 1) # <<<<<<<<<<<<<<
@@ -2377,7 +2666,7 @@ static int __pyx_pf_5_cdec_11DenseVector_4__setitem__(struct __pyx_obj_5_cdec_De
}
__pyx_L4:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":20
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":29
* if self.vector.size() <= fid:
* self.vector.resize(fid + 1)
* self.vector[0][fid] = value # <<<<<<<<<<<<<<
@@ -2397,20 +2686,20 @@ static int __pyx_pf_5_cdec_11DenseVector_4__setitem__(struct __pyx_obj_5_cdec_De
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_11DenseVector_8generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+static PyObject *__pyx_gb_5_cdec_11DenseVector_12generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_11DenseVector_7__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_11DenseVector_7__iter__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pw_5_cdec_11DenseVector_11__iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_11DenseVector_11__iter__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_11DenseVector_6__iter__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_11DenseVector_10__iter__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":22
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":31
* self.vector[0][fid] = value
*
* def __iter__(self): # <<<<<<<<<<<<<<
@@ -2418,7 +2707,7 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_7__iter__(PyObject *__pyx_v_self)
* for fid in range(1, self.vector.size()):
*/
-static PyObject *__pyx_pf_5_cdec_11DenseVector_6__iter__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_11DenseVector_10__iter__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) {
struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@@ -2436,7 +2725,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_6__iter__(struct __pyx_obj_5_cdec
__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_11DenseVector_8generator, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_11DenseVector_12generator, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -2454,7 +2743,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_6__iter__(struct __pyx_obj_5_cdec
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_11DenseVector_8generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+static PyObject *__pyx_gb_5_cdec_11DenseVector_12generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ *)__pyx_generator->closure);
PyObject *__pyx_r = NULL;
@@ -2473,9 +2762,9 @@ static PyObject *__pyx_gb_5_cdec_11DenseVector_8generator(__pyx_GeneratorObject
return NULL;
}
__pyx_L3_first_run:;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":24
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":33
* def __iter__(self):
* cdef unsigned fid
* for fid in range(1, self.vector.size()): # <<<<<<<<<<<<<<
@@ -2486,18 +2775,18 @@ static PyObject *__pyx_gb_5_cdec_11DenseVector_8generator(__pyx_GeneratorObject
for (__pyx_t_2 = 1; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
__pyx_cur_scope->__pyx_v_fid = __pyx_t_2;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":25
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":34
* cdef unsigned fid
* for fid in range(1, self.vector.size()):
* yield FDConvert(fid).c_str(), self.vector[0][fid] # <<<<<<<<<<<<<<
*
* def dot(self, SparseVector other):
*/
- __pyx_t_3 = PyBytes_FromString(FD::Convert(__pyx_cur_scope->__pyx_v_fid).c_str()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyBytes_FromString(FD::Convert(__pyx_cur_scope->__pyx_v_fid).c_str()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
- __pyx_t_4 = PyFloat_FromDouble(((__pyx_cur_scope->__pyx_v_self->vector[0])[__pyx_cur_scope->__pyx_v_fid])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyFloat_FromDouble(((__pyx_cur_scope->__pyx_v_self->vector[0])[__pyx_cur_scope->__pyx_v_fid])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_3));
__Pyx_GIVEREF(((PyObject *)__pyx_t_3));
@@ -2517,7 +2806,7 @@ static PyObject *__pyx_gb_5_cdec_11DenseVector_8generator(__pyx_GeneratorObject
__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[1]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
@@ -2529,18 +2818,19 @@ static PyObject *__pyx_gb_5_cdec_11DenseVector_8generator(__pyx_GeneratorObject
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_11DenseVector_10dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
-static PyObject *__pyx_pw_5_cdec_11DenseVector_10dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
+static PyObject *__pyx_pw_5_cdec_11DenseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
+static PyObject *__pyx_pw_5_cdec_11DenseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("dot (wrapper)", 0);
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_11DenseVector_9dot(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other));
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_11DenseVector_13dot(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other));
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
@@ -2549,7 +2839,7 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_10dot(PyObject *__pyx_v_self, PyO
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":27
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":36
* yield FDConvert(fid).c_str(), self.vector[0][fid]
*
* def dot(self, SparseVector other): # <<<<<<<<<<<<<<
@@ -2557,7 +2847,7 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_10dot(PyObject *__pyx_v_self, PyO
*
*/
-static PyObject *__pyx_pf_5_cdec_11DenseVector_9dot(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other) {
+static PyObject *__pyx_pf_5_cdec_11DenseVector_13dot(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
@@ -2568,7 +2858,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_9dot(struct __pyx_obj_5_cdec_Dens
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("dot", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":28
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":37
*
* def dot(self, SparseVector other):
* return other.dot(self) # <<<<<<<<<<<<<<
@@ -2576,14 +2866,14 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_9dot(struct __pyx_obj_5_cdec_Dens
* def tosparse(self):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_other), __pyx_n_s__dot); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_other), __pyx_n_s__dot); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(((PyObject *)__pyx_v_self));
PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
__Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
@@ -2606,25 +2896,25 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_9dot(struct __pyx_obj_5_cdec_Dens
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_11DenseVector_12tosparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_5_cdec_11DenseVector_12tosparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pw_5_cdec_11DenseVector_16tosparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5_cdec_11DenseVector_16tosparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("tosparse (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_11DenseVector_11tosparse(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_11DenseVector_15tosparse(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":30
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":39
* return other.dot(self)
*
* def tosparse(self): # <<<<<<<<<<<<<<
- * cdef SparseVector sparse = SparseVector()
+ * cdef SparseVector sparse = SparseVector.__new__(SparseVector)
* sparse.vector = new FastSparseVector[weight_t]()
*/
-static PyObject *__pyx_pf_5_cdec_11DenseVector_11tosparse(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_11DenseVector_15tosparse(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) {
struct __pyx_obj_5_cdec_SparseVector *__pyx_v_sparse = 0;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@@ -2634,29 +2924,30 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_11tosparse(struct __pyx_obj_5_cde
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("tosparse", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":31
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":40
*
* def tosparse(self):
- * cdef SparseVector sparse = SparseVector() # <<<<<<<<<<<<<<
+ * cdef SparseVector sparse = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<<
* sparse.vector = new FastSparseVector[weight_t]()
* InitSparseVector(self.vector[0], sparse.vector)
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_sparse = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":32
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":41
* def tosparse(self):
- * cdef SparseVector sparse = SparseVector()
+ * cdef SparseVector sparse = SparseVector.__new__(SparseVector)
* sparse.vector = new FastSparseVector[weight_t]() # <<<<<<<<<<<<<<
* InitSparseVector(self.vector[0], sparse.vector)
* return sparse
*/
__pyx_v_sparse->vector = new FastSparseVector<weight_t>();
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":33
- * cdef SparseVector sparse = SparseVector()
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":42
+ * cdef SparseVector sparse = SparseVector.__new__(SparseVector)
* sparse.vector = new FastSparseVector[weight_t]()
* InitSparseVector(self.vector[0], sparse.vector) # <<<<<<<<<<<<<<
* return sparse
@@ -2664,7 +2955,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_11tosparse(struct __pyx_obj_5_cde
*/
Weights::InitSparseVector((__pyx_v_self->vector[0]), __pyx_v_sparse->vector);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":34
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":43
* sparse.vector = new FastSparseVector[weight_t]()
* InitSparseVector(self.vector[0], sparse.vector)
* return sparse # <<<<<<<<<<<<<<
@@ -2690,27 +2981,68 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_11tosparse(struct __pyx_obj_5_cde
}
/* Python wrapper */
-static void __pyx_pw_5_cdec_12SparseVector_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pw_5_cdec_12SparseVector_1__dealloc__(PyObject *__pyx_v_self) {
+static int __pyx_pw_5_cdec_12SparseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5_cdec_12SparseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ int __pyx_r;
__Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
- __pyx_pf_5_cdec_12SparseVector___dealloc__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
+ __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+ if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
+ __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
+ if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector___init__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
+ return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":39
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":48
* cdef FastSparseVector[weight_t]* vector
*
+ * def __init__(self): # <<<<<<<<<<<<<<
+ * self.vector = new FastSparseVector[weight_t]()
+ *
+ */
+
+static int __pyx_pf_5_cdec_12SparseVector___init__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__init__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":49
+ *
+ * def __init__(self):
+ * self.vector = new FastSparseVector[weight_t]() # <<<<<<<<<<<<<<
+ *
+ * def __dealloc__(self):
+ */
+ __pyx_v_self->vector = new FastSparseVector<weight_t>();
+
+ __pyx_r = 0;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static void __pyx_pw_5_cdec_12SparseVector_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_5_cdec_12SparseVector_3__dealloc__(PyObject *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+ __pyx_pf_5_cdec_12SparseVector_2__dealloc__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":51
+ * self.vector = new FastSparseVector[weight_t]()
+ *
* def __dealloc__(self): # <<<<<<<<<<<<<<
* del self.vector
*
*/
-static void __pyx_pf_5_cdec_12SparseVector___dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
+static void __pyx_pf_5_cdec_12SparseVector_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":40
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":52
*
* def __dealloc__(self):
* del self.vector # <<<<<<<<<<<<<<
@@ -2723,17 +3055,17 @@ static void __pyx_pf_5_cdec_12SparseVector___dealloc__(CYTHON_UNUSED struct __py
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_3copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_3copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_5copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_5copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("copy (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_2copy(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_4copy(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":42
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":54
* del self.vector
*
* def copy(self): # <<<<<<<<<<<<<<
@@ -2741,7 +3073,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_3copy(PyObject *__pyx_v_self, CY
*
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_2copy(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_4copy(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
@@ -2750,7 +3082,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_2copy(struct __pyx_obj_5_cdec_Sp
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("copy", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":43
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":55
*
* def copy(self):
* return self * 1 # <<<<<<<<<<<<<<
@@ -2758,7 +3090,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_2copy(struct __pyx_obj_5_cdec_Sp
* def __getitem__(self, char* fname):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_v_self), __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_v_self), __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -2777,14 +3109,14 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_2copy(struct __pyx_obj_5_cdec_Sp
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_5__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_5__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname) {
char *__pyx_v_fname;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
assert(__pyx_arg_fname); {
- __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
@@ -2792,12 +3124,12 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_5__getitem__(PyObject *__pyx_v_s
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_4__getitem__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((char *)__pyx_v_fname));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_6__getitem__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((char *)__pyx_v_fname));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":45
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":57
* return self * 1
*
* def __getitem__(self, char* fname): # <<<<<<<<<<<<<<
@@ -2805,7 +3137,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_5__getitem__(PyObject *__pyx_v_s
* if fid < 0: raise KeyError(fname)
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_4__getitem__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_6__getitem__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname) {
int __pyx_v_fid;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@@ -2817,7 +3149,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_4__getitem__(struct __pyx_obj_5_
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__getitem__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":46
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":58
*
* def __getitem__(self, char* fname):
* cdef int fid = FDConvert(fname) # <<<<<<<<<<<<<<
@@ -2826,7 +3158,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_4__getitem__(struct __pyx_obj_5_
*/
__pyx_v_fid = FD::Convert(__pyx_v_fname);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":47
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":59
* def __getitem__(self, char* fname):
* cdef int fid = FDConvert(fname)
* if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<<
@@ -2835,24 +3167,24 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_4__getitem__(struct __pyx_obj_5_
*/
__pyx_t_1 = (__pyx_v_fid < 0);
if (__pyx_t_1) {
- __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_2));
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
__Pyx_GIVEREF(((PyObject *)__pyx_t_2));
__pyx_t_2 = 0;
- __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
__Pyx_Raise(__pyx_t_2, 0, 0, 0);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- {__pyx_filename = __pyx_f[1]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[1]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":48
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":60
* cdef int fid = FDConvert(fname)
* if fid < 0: raise KeyError(fname)
* return self.vector.value(fid) # <<<<<<<<<<<<<<
@@ -2860,7 +3192,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_4__getitem__(struct __pyx_obj_5_
* def __setitem__(self, char* fname, float value):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->vector->value(__pyx_v_fid)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->vector->value(__pyx_v_fid)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
@@ -2880,18 +3212,18 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_4__getitem__(struct __pyx_obj_5_
}
/* Python wrapper */
-static int __pyx_pw_5_cdec_12SparseVector_7__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname, PyObject *__pyx_arg_value); /*proto*/
-static int __pyx_pw_5_cdec_12SparseVector_7__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname, PyObject *__pyx_arg_value) {
+static int __pyx_pw_5_cdec_12SparseVector_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname, PyObject *__pyx_arg_value); /*proto*/
+static int __pyx_pw_5_cdec_12SparseVector_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname, PyObject *__pyx_arg_value) {
char *__pyx_v_fname;
float __pyx_v_value;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
assert(__pyx_arg_fname); {
- __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
assert(__pyx_arg_value); {
- __pyx_v_value = __pyx_PyFloat_AsFloat(__pyx_arg_value); if (unlikely((__pyx_v_value == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_value = __pyx_PyFloat_AsFloat(__pyx_arg_value); if (unlikely((__pyx_v_value == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
@@ -2899,12 +3231,12 @@ static int __pyx_pw_5_cdec_12SparseVector_7__setitem__(PyObject *__pyx_v_self, P
__Pyx_RefNannyFinishContext();
return -1;
__pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_6__setitem__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((char *)__pyx_v_fname), ((float)__pyx_v_value));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_8__setitem__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((char *)__pyx_v_fname), ((float)__pyx_v_value));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":50
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":62
* return self.vector.value(fid)
*
* def __setitem__(self, char* fname, float value): # <<<<<<<<<<<<<<
@@ -2912,7 +3244,7 @@ static int __pyx_pw_5_cdec_12SparseVector_7__setitem__(PyObject *__pyx_v_self, P
* if fid < 0: raise KeyError(fname)
*/
-static int __pyx_pf_5_cdec_12SparseVector_6__setitem__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname, float __pyx_v_value) {
+static int __pyx_pf_5_cdec_12SparseVector_8__setitem__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname, float __pyx_v_value) {
int __pyx_v_fid;
int __pyx_r;
__Pyx_RefNannyDeclarations
@@ -2924,7 +3256,7 @@ static int __pyx_pf_5_cdec_12SparseVector_6__setitem__(struct __pyx_obj_5_cdec_S
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setitem__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":51
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":63
*
* def __setitem__(self, char* fname, float value):
* cdef int fid = FDConvert(<char *>fname) # <<<<<<<<<<<<<<
@@ -2933,7 +3265,7 @@ static int __pyx_pf_5_cdec_12SparseVector_6__setitem__(struct __pyx_obj_5_cdec_S
*/
__pyx_v_fid = FD::Convert(((char *)__pyx_v_fname));
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":52
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":64
* def __setitem__(self, char* fname, float value):
* cdef int fid = FDConvert(<char *>fname)
* if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<<
@@ -2942,24 +3274,24 @@ static int __pyx_pf_5_cdec_12SparseVector_6__setitem__(struct __pyx_obj_5_cdec_S
*/
__pyx_t_1 = (__pyx_v_fid < 0);
if (__pyx_t_1) {
- __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_2));
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
__Pyx_GIVEREF(((PyObject *)__pyx_t_2));
__pyx_t_2 = 0;
- __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
__Pyx_Raise(__pyx_t_2, 0, 0, 0);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- {__pyx_filename = __pyx_f[1]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[1]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":53
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":65
* cdef int fid = FDConvert(<char *>fname)
* if fid < 0: raise KeyError(fname)
* self.vector.set_value(fid, value) # <<<<<<<<<<<<<<
@@ -2979,20 +3311,20 @@ static int __pyx_pf_5_cdec_12SparseVector_6__setitem__(struct __pyx_obj_5_cdec_S
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_12SparseVector_10generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_9__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_9__iter__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_11__iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_11__iter__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_8__iter__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_10__iter__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":55
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":67
* self.vector.set_value(fid, value)
*
* def __iter__(self): # <<<<<<<<<<<<<<
@@ -3000,7 +3332,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_9__iter__(PyObject *__pyx_v_self
* cdef unsigned i
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_8__iter__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_10__iter__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@@ -3018,7 +3350,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_8__iter__(struct __pyx_obj_5_cde
__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_12SparseVector_10generator1, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_12SparseVector_12generator1, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -3036,7 +3368,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_8__iter__(struct __pyx_obj_5_cde
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_12SparseVector_10generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ *)__pyx_generator->closure);
PyObject *__pyx_r = NULL;
@@ -3055,9 +3387,9 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_10generator1(__pyx_GeneratorObje
return NULL;
}
__pyx_L3_first_run:;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":56
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":68
*
* def __iter__(self):
* cdef FastSparseVector[weight_t].const_iterator* it = new FastSparseVector[weight_t].const_iterator(self.vector[0], False) # <<<<<<<<<<<<<<
@@ -3066,7 +3398,7 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_10generator1(__pyx_GeneratorObje
*/
__pyx_cur_scope->__pyx_v_it = new FastSparseVector<weight_t>::const_iterator((__pyx_cur_scope->__pyx_v_self->vector[0]), 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":58
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":70
* cdef FastSparseVector[weight_t].const_iterator* it = new FastSparseVector[weight_t].const_iterator(self.vector[0], False)
* cdef unsigned i
* try: # <<<<<<<<<<<<<<
@@ -3075,7 +3407,7 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_10generator1(__pyx_GeneratorObje
*/
/*try:*/ {
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":59
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":71
* cdef unsigned i
* try:
* for i in range(self.vector.size()): # <<<<<<<<<<<<<<
@@ -3086,18 +3418,18 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_10generator1(__pyx_GeneratorObje
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/vectors.pxi":60
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":72
* try:
* for i in range(self.vector.size()):
* yield (FDConvert(it[0].ptr().first).c_str(), it[0].ptr().second) # <<<<<<<<<<<<<<
* pinc(it[0]) # ++it
* finally:
*/
- __pyx_t_3 = PyBytes_FromString(FD::Convert((__pyx_cur_scope->__pyx_v_it[0]).operator->()->first).c_str()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L5;}
+ __pyx_t_3 = PyBytes_FromString(FD::Convert((__pyx_cur_scope->__pyx_v_it[0]).operator->()->first).c_str()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;}
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
- __pyx_t_4 = PyFloat_FromDouble((__pyx_cur_scope->__pyx_v_it[0]).operator->()->second); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L5;}
+ __pyx_t_4 = PyFloat_FromDouble((__pyx_cur_scope->__pyx_v_it[0]).operator->()->second); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L5;}
+ __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;}
__Pyx_GOTREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_3));
__Pyx_GIVEREF(((PyObject *)__pyx_t_3));
@@ -3117,9 +3449,9 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_10generator1(__pyx_GeneratorObje
__pyx_L9_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[1]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L5;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;}
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":61
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":73
* for i in range(self.vector.size()):
* yield (FDConvert(it[0].ptr().first).c_str(), it[0].ptr().second)
* pinc(it[0]) # ++it # <<<<<<<<<<<<<<
@@ -3130,7 +3462,7 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_10generator1(__pyx_GeneratorObje
}
}
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":63
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":75
* pinc(it[0]) # ++it
* finally:
* del it # <<<<<<<<<<<<<<
@@ -3175,22 +3507,23 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_10generator1(__pyx_GeneratorObje
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_12dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_12dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("dot (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_11dot(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((PyObject *)__pyx_v_other));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_13dot(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((PyObject *)__pyx_v_other));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":65
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":77
* del it
*
* def dot(self, other): # <<<<<<<<<<<<<<
@@ -3198,7 +3531,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_12dot(PyObject *__pyx_v_self, Py
* return self.vector.dot((<DenseVector> other).vector[0])
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_11dot(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, PyObject *__pyx_v_other) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, PyObject *__pyx_v_other) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
@@ -3209,7 +3542,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_11dot(struct __pyx_obj_5_cdec_Sp
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("dot", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":66
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":78
*
* def dot(self, other):
* if isinstance(other, DenseVector): # <<<<<<<<<<<<<<
@@ -3222,7 +3555,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_11dot(struct __pyx_obj_5_cdec_Sp
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_2) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":67
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":79
* def dot(self, other):
* if isinstance(other, DenseVector):
* return self.vector.dot((<DenseVector> other).vector[0]) # <<<<<<<<<<<<<<
@@ -3230,7 +3563,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_11dot(struct __pyx_obj_5_cdec_Sp
* return self.vector.dot((<SparseVector> other).vector[0])
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->vector->dot((((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_other)->vector[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->vector->dot((((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_other)->vector[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -3238,7 +3571,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_11dot(struct __pyx_obj_5_cdec_Sp
goto __pyx_L3;
}
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":68
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":80
* if isinstance(other, DenseVector):
* return self.vector.dot((<DenseVector> other).vector[0])
* elif isinstance(other, SparseVector): # <<<<<<<<<<<<<<
@@ -3251,7 +3584,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_11dot(struct __pyx_obj_5_cdec_Sp
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_2) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":69
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":81
* return self.vector.dot((<DenseVector> other).vector[0])
* elif isinstance(other, SparseVector):
* return self.vector.dot((<SparseVector> other).vector[0]) # <<<<<<<<<<<<<<
@@ -3259,7 +3592,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_11dot(struct __pyx_obj_5_cdec_Sp
*
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->vector->dot((((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other)->vector[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->vector->dot((((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other)->vector[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -3268,26 +3601,26 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_11dot(struct __pyx_obj_5_cdec_Sp
}
__pyx_L3:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":70
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":82
* elif isinstance(other, SparseVector):
* return self.vector.dot((<SparseVector> other).vector[0])
* raise TypeError('cannot take the dot product of %s and SparseVector' % type(other)) # <<<<<<<<<<<<<<
*
* def __richcmp__(SparseVector x, SparseVector y, int op):
*/
- __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), ((PyObject *)Py_TYPE(__pyx_v_other))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), ((PyObject *)Py_TYPE(__pyx_v_other))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
__Pyx_GIVEREF(((PyObject *)__pyx_t_1));
__pyx_t_1 = 0;
- __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- {__pyx_filename = __pyx_f[1]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
@@ -3303,14 +3636,14 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_11dot(struct __pyx_obj_5_cdec_Sp
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_14__richcmp__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_14__richcmp__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_16__richcmp__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_16__richcmp__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_13__richcmp__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y), ((int)__pyx_v_op));
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_15__richcmp__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y), ((int)__pyx_v_op));
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
@@ -3319,7 +3652,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_14__richcmp__(PyObject *__pyx_v_
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":72
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":84
* raise TypeError('cannot take the dot product of %s and SparseVector' % type(other))
*
* def __richcmp__(SparseVector x, SparseVector y, int op): # <<<<<<<<<<<<<<
@@ -3327,7 +3660,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_14__richcmp__(PyObject *__pyx_v_
* return x.vector[0] == y.vector[0]
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_13__richcmp__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y, int __pyx_v_op) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y, int __pyx_v_op) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
@@ -3337,7 +3670,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13__richcmp__(struct __pyx_obj_5
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__richcmp__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":75
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":87
* if op == 2: # ==
* return x.vector[0] == y.vector[0]
* elif op == 3: # != # <<<<<<<<<<<<<<
@@ -3346,7 +3679,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13__richcmp__(struct __pyx_obj_5
*/
switch (__pyx_v_op) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":73
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":85
*
* def __richcmp__(SparseVector x, SparseVector y, int op):
* if op == 2: # == # <<<<<<<<<<<<<<
@@ -3355,7 +3688,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13__richcmp__(struct __pyx_obj_5
*/
case 2:
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":74
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":86
* def __richcmp__(SparseVector x, SparseVector y, int op):
* if op == 2: # ==
* return x.vector[0] == y.vector[0] # <<<<<<<<<<<<<<
@@ -3363,14 +3696,14 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13__richcmp__(struct __pyx_obj_5
* return not (x == y)
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(((__pyx_v_x->vector[0]) == (__pyx_v_y->vector[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_PyBool_FromLong(((__pyx_v_x->vector[0]) == (__pyx_v_y->vector[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
break;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":75
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":87
* if op == 2: # ==
* return x.vector[0] == y.vector[0]
* elif op == 3: # != # <<<<<<<<<<<<<<
@@ -3379,7 +3712,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13__richcmp__(struct __pyx_obj_5
*/
case 3:
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":76
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":88
* return x.vector[0] == y.vector[0]
* elif op == 3: # !=
* return not (x == y) # <<<<<<<<<<<<<<
@@ -3387,11 +3720,11 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13__richcmp__(struct __pyx_obj_5
*
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -3399,18 +3732,18 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13__richcmp__(struct __pyx_obj_5
break;
}
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":77
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":89
* elif op == 3: # !=
* return not (x == y)
* raise NotImplemented('comparison not implemented for SparseVector') # <<<<<<<<<<<<<<
*
* def __len__(self):
*/
- __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
@@ -3425,17 +3758,17 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13__richcmp__(struct __pyx_obj_5
}
/* Python wrapper */
-static Py_ssize_t __pyx_pw_5_cdec_12SparseVector_16__len__(PyObject *__pyx_v_self); /*proto*/
-static Py_ssize_t __pyx_pw_5_cdec_12SparseVector_16__len__(PyObject *__pyx_v_self) {
+static Py_ssize_t __pyx_pw_5_cdec_12SparseVector_18__len__(PyObject *__pyx_v_self); /*proto*/
+static Py_ssize_t __pyx_pw_5_cdec_12SparseVector_18__len__(PyObject *__pyx_v_self) {
Py_ssize_t __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_15__len__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_17__len__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":79
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":91
* raise NotImplemented('comparison not implemented for SparseVector')
*
* def __len__(self): # <<<<<<<<<<<<<<
@@ -3443,12 +3776,12 @@ static Py_ssize_t __pyx_pw_5_cdec_12SparseVector_16__len__(PyObject *__pyx_v_sel
*
*/
-static Py_ssize_t __pyx_pf_5_cdec_12SparseVector_15__len__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
+static Py_ssize_t __pyx_pf_5_cdec_12SparseVector_17__len__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
Py_ssize_t __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__len__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":80
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":92
*
* def __len__(self):
* return self.vector.size() # <<<<<<<<<<<<<<
@@ -3465,14 +3798,14 @@ static Py_ssize_t __pyx_pf_5_cdec_12SparseVector_15__len__(struct __pyx_obj_5_cd
}
/* Python wrapper */
-static int __pyx_pw_5_cdec_12SparseVector_18__contains__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname); /*proto*/
-static int __pyx_pw_5_cdec_12SparseVector_18__contains__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname) {
+static int __pyx_pw_5_cdec_12SparseVector_20__contains__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname); /*proto*/
+static int __pyx_pw_5_cdec_12SparseVector_20__contains__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname) {
char *__pyx_v_fname;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
assert(__pyx_arg_fname); {
- __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
@@ -3480,12 +3813,12 @@ static int __pyx_pw_5_cdec_12SparseVector_18__contains__(PyObject *__pyx_v_self,
__Pyx_RefNannyFinishContext();
return -1;
__pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_17__contains__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((char *)__pyx_v_fname));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_19__contains__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((char *)__pyx_v_fname));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":82
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":94
* return self.vector.size()
*
* def __contains__(self, char* fname): # <<<<<<<<<<<<<<
@@ -3493,12 +3826,12 @@ static int __pyx_pw_5_cdec_12SparseVector_18__contains__(PyObject *__pyx_v_self,
*
*/
-static int __pyx_pf_5_cdec_12SparseVector_17__contains__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname) {
+static int __pyx_pf_5_cdec_12SparseVector_19__contains__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__contains__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":83
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":95
*
* def __contains__(self, char* fname):
* return self.vector.nonzero(FDConvert(fname)) # <<<<<<<<<<<<<<
@@ -3515,25 +3848,25 @@ static int __pyx_pf_5_cdec_12SparseVector_17__contains__(struct __pyx_obj_5_cdec
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_20__neg__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_20__neg__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_22__neg__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_22__neg__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__neg__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_19__neg__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_21__neg__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":85
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":97
* return self.vector.nonzero(FDConvert(fname))
*
* def __neg__(self): # <<<<<<<<<<<<<<
- * cdef SparseVector result = SparseVector()
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](self.vector[0])
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_19__neg__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_21__neg__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
struct __pyx_obj_5_cdec_SparseVector *__pyx_v_result = 0;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@@ -3543,29 +3876,30 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_19__neg__(struct __pyx_obj_5_cde
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__neg__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":86
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":98
*
* def __neg__(self):
- * cdef SparseVector result = SparseVector() # <<<<<<<<<<<<<<
+ * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<<
* result.vector = new FastSparseVector[weight_t](self.vector[0])
* result.vector[0] *= -1.0
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":87
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":99
* def __neg__(self):
- * cdef SparseVector result = SparseVector()
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](self.vector[0]) # <<<<<<<<<<<<<<
* result.vector[0] *= -1.0
* return result
*/
__pyx_v_result->vector = new FastSparseVector<weight_t>((__pyx_v_self->vector[0]));
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":88
- * cdef SparseVector result = SparseVector()
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":100
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](self.vector[0])
* result.vector[0] *= -1.0 # <<<<<<<<<<<<<<
* return result
@@ -3573,7 +3907,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_19__neg__(struct __pyx_obj_5_cde
*/
(__pyx_v_result->vector[0]) *= -1.0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":89
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":101
* result.vector = new FastSparseVector[weight_t](self.vector[0])
* result.vector[0] *= -1.0
* return result # <<<<<<<<<<<<<<
@@ -3599,13 +3933,13 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_19__neg__(struct __pyx_obj_5_cde
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_22__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_22__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_24__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_24__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__iadd__ (wrapper)", 0);
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_21__iadd__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other));
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_23__iadd__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other));
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
@@ -3614,7 +3948,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_22__iadd__(PyObject *__pyx_v_sel
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":91
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":103
* return result
*
* def __iadd__(SparseVector self, SparseVector other): # <<<<<<<<<<<<<<
@@ -3622,12 +3956,12 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_22__iadd__(PyObject *__pyx_v_sel
* return self
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_21__iadd__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_23__iadd__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__iadd__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":92
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":104
*
* def __iadd__(SparseVector self, SparseVector other):
* self.vector[0] += other.vector[0] # <<<<<<<<<<<<<<
@@ -3636,7 +3970,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_21__iadd__(struct __pyx_obj_5_cd
*/
(__pyx_v_self->vector[0]) += (__pyx_v_other->vector[0]);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":93
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":105
* def __iadd__(SparseVector self, SparseVector other):
* self.vector[0] += other.vector[0]
* return self # <<<<<<<<<<<<<<
@@ -3656,13 +3990,13 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_21__iadd__(struct __pyx_obj_5_cd
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_24__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_24__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_26__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_26__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__isub__ (wrapper)", 0);
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_23__isub__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other));
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_25__isub__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other));
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
@@ -3671,7 +4005,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_24__isub__(PyObject *__pyx_v_sel
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":95
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":107
* return self
*
* def __isub__(SparseVector self, SparseVector other): # <<<<<<<<<<<<<<
@@ -3679,12 +4013,12 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_24__isub__(PyObject *__pyx_v_sel
* return self
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_23__isub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_25__isub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__isub__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":96
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":108
*
* def __isub__(SparseVector self, SparseVector other):
* self.vector[0] -= other.vector[0] # <<<<<<<<<<<<<<
@@ -3693,7 +4027,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_23__isub__(struct __pyx_obj_5_cd
*/
(__pyx_v_self->vector[0]) -= (__pyx_v_other->vector[0]);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":97
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":109
* def __isub__(SparseVector self, SparseVector other):
* self.vector[0] -= other.vector[0]
* return self # <<<<<<<<<<<<<<
@@ -3713,14 +4047,14 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_23__isub__(struct __pyx_obj_5_cd
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_26__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_26__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_28__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_28__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar) {
float __pyx_v_scalar;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__imul__ (wrapper)", 0);
assert(__pyx_arg_scalar); {
- __pyx_v_scalar = __pyx_PyFloat_AsFloat(__pyx_arg_scalar); if (unlikely((__pyx_v_scalar == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_scalar = __pyx_PyFloat_AsFloat(__pyx_arg_scalar); if (unlikely((__pyx_v_scalar == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
@@ -3728,12 +4062,12 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_26__imul__(PyObject *__pyx_v_sel
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_25__imul__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((float)__pyx_v_scalar));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_27__imul__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((float)__pyx_v_scalar));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":99
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":111
* return self
*
* def __imul__(SparseVector self, float scalar): # <<<<<<<<<<<<<<
@@ -3741,12 +4075,12 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_26__imul__(PyObject *__pyx_v_sel
* return self
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_25__imul__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_27__imul__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__imul__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":100
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":112
*
* def __imul__(SparseVector self, float scalar):
* self.vector[0] *= scalar # <<<<<<<<<<<<<<
@@ -3755,7 +4089,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_25__imul__(struct __pyx_obj_5_cd
*/
(__pyx_v_self->vector[0]) *= __pyx_v_scalar;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":101
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":113
* def __imul__(SparseVector self, float scalar):
* self.vector[0] *= scalar
* return self # <<<<<<<<<<<<<<
@@ -3776,14 +4110,14 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_25__imul__(struct __pyx_obj_5_cd
/* Python wrapper */
#if PY_MAJOR_VERSION < 3
-static PyObject *__pyx_pw_5_cdec_12SparseVector_28__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_28__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_30__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_30__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar) {
float __pyx_v_scalar;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__idiv__ (wrapper)", 0);
assert(__pyx_arg_scalar); {
- __pyx_v_scalar = __pyx_PyFloat_AsFloat(__pyx_arg_scalar); if (unlikely((__pyx_v_scalar == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_scalar = __pyx_PyFloat_AsFloat(__pyx_arg_scalar); if (unlikely((__pyx_v_scalar == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
@@ -3791,13 +4125,13 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_28__idiv__(PyObject *__pyx_v_sel
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_27__idiv__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((float)__pyx_v_scalar));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_29__idiv__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((float)__pyx_v_scalar));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":103
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":115
* return self
*
* def __idiv__(SparseVector self, float scalar): # <<<<<<<<<<<<<<
@@ -3806,12 +4140,12 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_28__idiv__(PyObject *__pyx_v_sel
*/
#if PY_MAJOR_VERSION < 3
-static PyObject *__pyx_pf_5_cdec_12SparseVector_27__idiv__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_29__idiv__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__idiv__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":104
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":116
*
* def __idiv__(SparseVector self, float scalar):
* self.vector[0] /= scalar # <<<<<<<<<<<<<<
@@ -3820,7 +4154,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_27__idiv__(struct __pyx_obj_5_cd
*/
(__pyx_v_self->vector[0]) /= __pyx_v_scalar;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":105
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":117
* def __idiv__(SparseVector self, float scalar):
* self.vector[0] /= scalar
* return self # <<<<<<<<<<<<<<
@@ -3841,14 +4175,14 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_27__idiv__(struct __pyx_obj_5_cd
#endif /*!(#if PY_MAJOR_VERSION < 3)*/
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_30__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_30__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_32__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_32__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_29__add__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y));
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_31__add__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y));
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
@@ -3857,15 +4191,15 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_30__add__(PyObject *__pyx_v_x, P
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":107
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":119
* return self
*
* def __add__(SparseVector x, SparseVector y): # <<<<<<<<<<<<<<
- * cdef SparseVector result = SparseVector()
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0])
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_29__add__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_31__add__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y) {
struct __pyx_obj_5_cdec_SparseVector *__pyx_v_result = 0;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@@ -3875,29 +4209,30 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_29__add__(struct __pyx_obj_5_cde
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__add__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":108
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":120
*
* def __add__(SparseVector x, SparseVector y):
- * cdef SparseVector result = SparseVector() # <<<<<<<<<<<<<<
+ * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<<
* result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0])
* return result
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":109
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":121
* def __add__(SparseVector x, SparseVector y):
- * cdef SparseVector result = SparseVector()
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0]) # <<<<<<<<<<<<<<
* return result
*
*/
__pyx_v_result->vector = new FastSparseVector<weight_t>(((__pyx_v_x->vector[0]) + (__pyx_v_y->vector[0])));
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":110
- * cdef SparseVector result = SparseVector()
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":122
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0])
* return result # <<<<<<<<<<<<<<
*
@@ -3922,14 +4257,14 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_29__add__(struct __pyx_obj_5_cde
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_32__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_32__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_34__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_34__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__sub__ (wrapper)", 0);
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_31__sub__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y));
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_33__sub__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y));
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
@@ -3938,15 +4273,15 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_32__sub__(PyObject *__pyx_v_x, P
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":112
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":124
* return result
*
* def __sub__(SparseVector x, SparseVector y): # <<<<<<<<<<<<<<
- * cdef SparseVector result = SparseVector()
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0])
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_31__sub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_33__sub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y) {
struct __pyx_obj_5_cdec_SparseVector *__pyx_v_result = 0;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@@ -3956,29 +4291,30 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_31__sub__(struct __pyx_obj_5_cde
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__sub__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":113
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":125
*
* def __sub__(SparseVector x, SparseVector y):
- * cdef SparseVector result = SparseVector() # <<<<<<<<<<<<<<
+ * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<<
* result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0])
* return result
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":114
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":126
* def __sub__(SparseVector x, SparseVector y):
- * cdef SparseVector result = SparseVector()
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0]) # <<<<<<<<<<<<<<
* return result
*
*/
__pyx_v_result->vector = new FastSparseVector<weight_t>(((__pyx_v_x->vector[0]) - (__pyx_v_y->vector[0])));
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":115
- * cdef SparseVector result = SparseVector()
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":127
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0])
* return result # <<<<<<<<<<<<<<
*
@@ -4003,17 +4339,17 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_31__sub__(struct __pyx_obj_5_cde
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_34__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_34__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_36__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_36__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__mul__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_33__mul__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_35__mul__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":117
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":129
* return result
*
* def __mul__(x, y): # <<<<<<<<<<<<<<
@@ -4021,7 +4357,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_34__mul__(PyObject *__pyx_v_x, P
* cdef float scalar
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_33__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_35__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
struct __pyx_obj_5_cdec_SparseVector *__pyx_v_vector = 0;
float __pyx_v_scalar;
struct __pyx_obj_5_cdec_SparseVector *__pyx_v_result = 0;
@@ -4035,22 +4371,22 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_33__mul__(PyObject *__pyx_v_x, P
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__mul__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":120
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":132
* cdef SparseVector vector
* cdef float scalar
* if isinstance(x, SparseVector): vector, scalar = x, y # <<<<<<<<<<<<<<
* else: vector, scalar = y, x
- * cdef SparseVector result = SparseVector()
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
*/
__pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector));
__Pyx_INCREF(__pyx_t_1);
__pyx_t_2 = __Pyx_TypeCheck(__pyx_v_x, __pyx_t_1);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_2) {
- if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_1 = __pyx_v_x;
__Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_y); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_y); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
__pyx_v_scalar = __pyx_t_3;
@@ -4058,46 +4394,47 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_33__mul__(PyObject *__pyx_v_x, P
}
/*else*/ {
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":121
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":133
* cdef float scalar
* if isinstance(x, SparseVector): vector, scalar = x, y
* else: vector, scalar = y, x # <<<<<<<<<<<<<<
- * cdef SparseVector result = SparseVector()
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar)
*/
- if (!(likely(((__pyx_v_y) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_y, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(((__pyx_v_y) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_y, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_1 = __pyx_v_y;
__Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_x); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_x); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
__pyx_v_scalar = __pyx_t_3;
}
__pyx_L3:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":122
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":134
* if isinstance(x, SparseVector): vector, scalar = x, y
* else: vector, scalar = y, x
- * cdef SparseVector result = SparseVector() # <<<<<<<<<<<<<<
+ * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<<
* result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar)
* return result
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":123
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":135
* else: vector, scalar = y, x
- * cdef SparseVector result = SparseVector()
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar) # <<<<<<<<<<<<<<
* return result
*
*/
__pyx_v_result->vector = new FastSparseVector<weight_t>(((__pyx_v_vector->vector[0]) * __pyx_v_scalar));
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":124
- * cdef SparseVector result = SparseVector()
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":136
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar)
* return result # <<<<<<<<<<<<<<
*
@@ -4124,18 +4461,18 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_33__mul__(PyObject *__pyx_v_x, P
/* Python wrapper */
#if PY_MAJOR_VERSION < 3
-static PyObject *__pyx_pw_5_cdec_12SparseVector_36__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_36__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_38__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_38__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__div__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_35__div__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_37__div__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3)*/
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":126
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":138
* return result
*
* def __div__(x, y): # <<<<<<<<<<<<<<
@@ -4144,7 +4481,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_36__div__(PyObject *__pyx_v_x, P
*/
#if PY_MAJOR_VERSION < 3
-static PyObject *__pyx_pf_5_cdec_12SparseVector_35__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_37__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
struct __pyx_obj_5_cdec_SparseVector *__pyx_v_vector = 0;
float __pyx_v_scalar;
struct __pyx_obj_5_cdec_SparseVector *__pyx_v_result = 0;
@@ -4158,22 +4495,22 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_35__div__(PyObject *__pyx_v_x, P
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__div__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":129
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":141
* cdef SparseVector vector
* cdef float scalar
* if isinstance(x, SparseVector): vector, scalar = x, y # <<<<<<<<<<<<<<
* else: vector, scalar = y, x
- * cdef SparseVector result = SparseVector()
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
*/
__pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector));
__Pyx_INCREF(__pyx_t_1);
__pyx_t_2 = __Pyx_TypeCheck(__pyx_v_x, __pyx_t_1);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_2) {
- if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_1 = __pyx_v_x;
__Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_y); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_y); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
__pyx_v_scalar = __pyx_t_3;
@@ -4181,45 +4518,46 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_35__div__(PyObject *__pyx_v_x, P
}
/*else*/ {
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":130
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":142
* cdef float scalar
* if isinstance(x, SparseVector): vector, scalar = x, y
* else: vector, scalar = y, x # <<<<<<<<<<<<<<
- * cdef SparseVector result = SparseVector()
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar)
*/
- if (!(likely(((__pyx_v_y) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_y, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(((__pyx_v_y) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_y, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_1 = __pyx_v_y;
__Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_x); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_x); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
__pyx_v_scalar = __pyx_t_3;
}
__pyx_L3:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":131
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":143
* if isinstance(x, SparseVector): vector, scalar = x, y
* else: vector, scalar = y, x
- * cdef SparseVector result = SparseVector() # <<<<<<<<<<<<<<
+ * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<<
* result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar)
* return result
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":132
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":144
* else: vector, scalar = y, x
- * cdef SparseVector result = SparseVector()
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar) # <<<<<<<<<<<<<<
* return result
*/
__pyx_v_result->vector = new FastSparseVector<weight_t>(((__pyx_v_vector->vector[0]) / __pyx_v_scalar));
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":133
- * cdef SparseVector result = SparseVector()
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":145
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
* result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar)
* return result # <<<<<<<<<<<<<<
*/
@@ -4250,14 +4588,13 @@ static PyObject *__pyx_pw_5_cdec_1_phrase(PyObject *__pyx_self, PyObject *__pyx_
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("_phrase (wrapper)", 0);
- __pyx_self = __pyx_self;
__pyx_r = __pyx_pf_5_cdec__phrase(__pyx_self, ((PyObject *)__pyx_v_phrase));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_5_cdec_7_phrase_2generator17(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":4
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":6
*
* def _phrase(phrase):
* return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) # <<<<<<<<<<<<<<
@@ -4283,7 +4620,7 @@ static PyObject *__pyx_pf_5_cdec_7_phrase_genexpr(PyObject *__pyx_self) {
__Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
{
- __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7_phrase_2generator17, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7_phrase_2generator17, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -4322,29 +4659,37 @@ static PyObject *__pyx_gb_5_cdec_7_phrase_2generator17(__pyx_GeneratorObject *__
return NULL;
}
__pyx_L3_first_run:;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_phrase)) { __Pyx_RaiseClosureNameError("phrase"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_phrase)) { __Pyx_RaiseClosureNameError("phrase"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
if (PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_phrase) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_phrase)) {
__pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_phrase; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
__pyx_t_3 = NULL;
} else {
- __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_phrase); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_phrase); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __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 = 6; __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 = 6; __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 = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
break;
}
@@ -4360,20 +4705,20 @@ static PyObject *__pyx_gb_5_cdec_7_phrase_2generator17(__pyx_GeneratorObject *__
__pyx_t_6 = __Pyx_TypeCheck(__pyx_cur_scope->__pyx_v_w, __pyx_t_5);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
if (__pyx_t_6) {
- __pyx_t_5 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_w, __pyx_n_s__encode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_w, __pyx_n_s__encode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
- __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_4 = __pyx_t_7;
__pyx_t_7 = 0;
} else {
- __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_w);
PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_cur_scope->__pyx_v_w);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_w);
- __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
__pyx_t_4 = __pyx_t_5;
@@ -4396,7 +4741,7 @@ static PyObject *__pyx_gb_5_cdec_7_phrase_2generator17(__pyx_GeneratorObject *__
__Pyx_XGOTREF(__pyx_t_1);
__pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
__pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
PyErr_SetNone(PyExc_StopIteration);
@@ -4410,12 +4755,13 @@ static PyObject *__pyx_gb_5_cdec_7_phrase_2generator17(__pyx_GeneratorObject *__
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":3
- * cimport grammar
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5
+ * import cdec.sa._sa as _sa
*
* def _phrase(phrase): # <<<<<<<<<<<<<<
* return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase)
@@ -4443,7 +4789,7 @@ static PyObject *__pyx_pf_5_cdec__phrase(CYTHON_UNUSED PyObject *__pyx_self, PyO
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_phrase);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_phrase);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":4
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":6
*
* def _phrase(phrase):
* return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) # <<<<<<<<<<<<<<
@@ -4451,16 +4797,16 @@ static PyObject *__pyx_pf_5_cdec__phrase(CYTHON_UNUSED PyObject *__pyx_self, PyO
* cdef class NT:
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_7), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_7), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __pyx_pf_5_cdec_7_phrase_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = __pyx_pf_5_cdec_7_phrase_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
__Pyx_GIVEREF(__pyx_t_2);
__pyx_t_2 = 0;
- __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
@@ -4488,11 +4834,11 @@ static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx
static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_cat = 0;
PyObject *__pyx_v_ref = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__cat,&__pyx_n_s__ref,0};
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
{
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__cat,&__pyx_n_s__ref,0};
PyObject* values[2] = {0,0};
values[1] = ((PyObject *)__pyx_int_0);
if (unlikely(__pyx_kwds)) {
@@ -4507,8 +4853,7 @@ static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cat);
- if (likely(values[0])) kw_args--;
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cat)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (kw_args > 0) {
@@ -4517,7 +4862,7 @@ static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx
}
}
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 = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -4532,7 +4877,7 @@ static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("_cdec.NT.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
@@ -4543,7 +4888,7 @@ static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":9
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":11
* cdef public char* cat
* cdef public unsigned ref
* def __init__(self, cat, ref=0): # <<<<<<<<<<<<<<
@@ -4561,24 +4906,24 @@ static int __pyx_pf_5_cdec_2NT___init__(struct __pyx_obj_5_cdec_NT *__pyx_v_self
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__init__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":10
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":12
* cdef public unsigned ref
* def __init__(self, cat, ref=0):
* self.cat = cat # <<<<<<<<<<<<<<
* self.ref = ref
*
*/
- __pyx_t_1 = PyBytes_AsString(__pyx_v_cat); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_AsString(__pyx_v_cat); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_self->cat = __pyx_t_1;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":11
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":13
* def __init__(self, cat, ref=0):
* self.cat = cat
* self.ref = ref # <<<<<<<<<<<<<<
*
* def __str__(self):
*/
- __pyx_t_2 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_ref); if (unlikely((__pyx_t_2 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_ref); if (unlikely((__pyx_t_2 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_self->ref = __pyx_t_2;
__pyx_r = 0;
@@ -4602,7 +4947,7 @@ static PyObject *__pyx_pw_5_cdec_2NT_3__str__(PyObject *__pyx_v_self) {
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":13
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":15
* self.ref = ref
*
* def __str__(self): # <<<<<<<<<<<<<<
@@ -4622,7 +4967,7 @@ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__str__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":14
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":16
*
* def __str__(self):
* if self.ref > 0: # <<<<<<<<<<<<<<
@@ -4632,7 +4977,7 @@ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_
__pyx_t_1 = (__pyx_v_self->ref > 0);
if (__pyx_t_1) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":15
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":17
* def __str__(self):
* if self.ref > 0:
* return '[%s,%d]' % (self.cat, self.ref) # <<<<<<<<<<<<<<
@@ -4640,11 +4985,11 @@ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_
*
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = PyBytes_FromString(__pyx_v_self->cat); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyBytes_FromString(__pyx_v_self->cat); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_2));
- __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_2));
__Pyx_GIVEREF(((PyObject *)__pyx_t_2));
@@ -4652,7 +4997,7 @@ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_2 = 0;
__pyx_t_3 = 0;
- __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
__pyx_r = ((PyObject *)__pyx_t_3);
@@ -4662,7 +5007,7 @@ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_
}
__pyx_L3:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":16
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":18
* if self.ref > 0:
* return '[%s,%d]' % (self.cat, self.ref)
* return '[%s]' % self.cat # <<<<<<<<<<<<<<
@@ -4670,9 +5015,9 @@ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_
* cdef class NTRef:
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = PyBytes_FromString(__pyx_v_self->cat); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyBytes_FromString(__pyx_v_self->cat); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
- __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
__pyx_r = ((PyObject *)__pyx_t_4);
@@ -4704,7 +5049,7 @@ static PyObject *__pyx_pw_5_cdec_2NT_3cat_1__get__(PyObject *__pyx_v_self) {
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":7
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":9
*
* cdef class NT:
* cdef public char* cat # <<<<<<<<<<<<<<
@@ -4721,7 +5066,7 @@ static PyObject *__pyx_pf_5_cdec_2NT_3cat___get__(struct __pyx_obj_5_cdec_NT *__
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyBytes_FromString(__pyx_v_self->cat); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_FromString(__pyx_v_self->cat); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
__pyx_r = ((PyObject *)__pyx_t_1);
__pyx_t_1 = 0;
@@ -4758,7 +5103,7 @@ static int __pyx_pf_5_cdec_2NT_3cat_2__set__(struct __pyx_obj_5_cdec_NT *__pyx_v
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__set__", 0);
- __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_self->cat = __pyx_t_1;
__pyx_r = 0;
@@ -4782,7 +5127,7 @@ static PyObject *__pyx_pw_5_cdec_2NT_3ref_1__get__(PyObject *__pyx_v_self) {
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":8
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":10
* cdef class NT:
* cdef public char* cat
* cdef public unsigned ref # <<<<<<<<<<<<<<
@@ -4799,7 +5144,7 @@ static PyObject *__pyx_pf_5_cdec_2NT_3ref___get__(struct __pyx_obj_5_cdec_NT *__
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -4836,7 +5181,7 @@ static int __pyx_pf_5_cdec_2NT_3ref_2__set__(struct __pyx_obj_5_cdec_NT *__pyx_v
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__set__", 0);
- __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_self->ref = __pyx_t_1;
__pyx_r = 0;
@@ -4853,11 +5198,11 @@ static int __pyx_pf_5_cdec_2NT_3ref_2__set__(struct __pyx_obj_5_cdec_NT *__pyx_v
static int __pyx_pw_5_cdec_5NTRef_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5_cdec_5NTRef_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_ref = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__ref,0};
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
{
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__ref,0};
PyObject* values[1] = {0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
@@ -4870,12 +5215,11 @@ static int __pyx_pw_5_cdec_5NTRef_1__init__(PyObject *__pyx_v_self, PyObject *__
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ref);
- if (likely(values[0])) kw_args--;
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ref)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
}
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 = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
goto __pyx_L5_argtuple_error;
@@ -4886,7 +5230,7 @@ static int __pyx_pw_5_cdec_5NTRef_1__init__(PyObject *__pyx_v_self, PyObject *__
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("_cdec.NTRef.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
@@ -4897,7 +5241,7 @@ static int __pyx_pw_5_cdec_5NTRef_1__init__(PyObject *__pyx_v_self, PyObject *__
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":20
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":22
* cdef class NTRef:
* cdef public unsigned ref
* def __init__(self, ref): # <<<<<<<<<<<<<<
@@ -4914,14 +5258,14 @@ static int __pyx_pf_5_cdec_5NTRef___init__(struct __pyx_obj_5_cdec_NTRef *__pyx_
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__init__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":21
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":23
* cdef public unsigned ref
* def __init__(self, ref):
* self.ref = ref # <<<<<<<<<<<<<<
*
* def __str__(self):
*/
- __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_ref); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_ref); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_self->ref = __pyx_t_1;
__pyx_r = 0;
@@ -4945,7 +5289,7 @@ static PyObject *__pyx_pw_5_cdec_5NTRef_3__str__(PyObject *__pyx_v_self) {
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":23
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":25
* self.ref = ref
*
* def __str__(self): # <<<<<<<<<<<<<<
@@ -4963,17 +5307,17 @@ static PyObject *__pyx_pf_5_cdec_5NTRef_2__str__(struct __pyx_obj_5_cdec_NTRef *
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__str__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":24
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":26
*
* def __str__(self):
* return '[%d]' % self.ref # <<<<<<<<<<<<<<
*
- * cdef class BaseTRule:
+ * cdef TRule convert_rule(_sa.Rule rule):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_2));
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_r = ((PyObject *)__pyx_t_2);
@@ -5004,7 +5348,7 @@ static PyObject *__pyx_pw_5_cdec_5NTRef_3ref_1__get__(PyObject *__pyx_v_self) {
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":19
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":21
*
* cdef class NTRef:
* cdef public unsigned ref # <<<<<<<<<<<<<<
@@ -5021,7 +5365,7 @@ static PyObject *__pyx_pf_5_cdec_5NTRef_3ref___get__(struct __pyx_obj_5_cdec_NTR
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -5058,7 +5402,7 @@ static int __pyx_pf_5_cdec_5NTRef_3ref_2__set__(struct __pyx_obj_5_cdec_NTRef *_
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__set__", 0);
- __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_self->ref = __pyx_t_1;
__pyx_r = 0;
@@ -5071,28 +5415,589 @@ static int __pyx_pf_5_cdec_5NTRef_3ref_2__set__(struct __pyx_obj_5_cdec_NTRef *_
return __pyx_r;
}
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":28
+ * return '[%d]' % self.ref
+ *
+ * cdef TRule convert_rule(_sa.Rule rule): # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * cdef lhs = _sa.sym_tocat(rule.lhs)
+ */
+
+static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_obj_4cdec_2sa_3_sa_Rule *__pyx_v_rule) {
+ unsigned int __pyx_v_i;
+ PyObject *__pyx_v_lhs = 0;
+ PyObject *__pyx_v_scores = 0;
+ PyObject *__pyx_v_f = NULL;
+ PyObject *__pyx_v_e = NULL;
+ int *__pyx_v_fsyms;
+ int *__pyx_v_esyms;
+ PyObject *__pyx_v_a = 0;
+ PyObject *__pyx_v_point = NULL;
+ struct __pyx_obj_5_cdec_TRule *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_t_2;
+ unsigned int __pyx_t_3;
+ PyObject *__pyx_t_4 = NULL;
+ PyObject *__pyx_t_5 = NULL;
+ int __pyx_t_6;
+ int __pyx_t_7;
+ Py_ssize_t __pyx_t_8;
+ PyObject *(*__pyx_t_9)(PyObject *);
+ PyObject *__pyx_t_10 = NULL;
+ PyObject *__pyx_t_11 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("convert_rule", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":30
+ * cdef TRule convert_rule(_sa.Rule rule):
+ * cdef unsigned i
+ * cdef lhs = _sa.sym_tocat(rule.lhs) # <<<<<<<<<<<<<<
+ * cdef scores = {}
+ * for i in range(rule.n_scores):
+ */
+ __pyx_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tocat(__pyx_v_rule->lhs)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_v_lhs = ((PyObject *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":31
+ * cdef unsigned i
+ * cdef lhs = _sa.sym_tocat(rule.lhs)
+ * cdef scores = {} # <<<<<<<<<<<<<<
+ * for i in range(rule.n_scores):
+ * scores['PhraseModel_'+str(i)] = rule.cscores[i]
+ */
+ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_v_scores = ((PyObject *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":32
+ * cdef lhs = _sa.sym_tocat(rule.lhs)
+ * cdef scores = {}
+ * for i in range(rule.n_scores): # <<<<<<<<<<<<<<
+ * scores['PhraseModel_'+str(i)] = rule.cscores[i]
+ * f, e = [], []
+ */
+ __pyx_t_2 = __pyx_v_rule->n_scores;
+ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
+ __pyx_v_i = __pyx_t_3;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":33
+ * cdef scores = {}
+ * for i in range(rule.n_scores):
+ * scores['PhraseModel_'+str(i)] = rule.cscores[i] # <<<<<<<<<<<<<<
+ * f, e = [], []
+ * cdef int* fsyms = rule.f.syms
+ */
+ __pyx_t_1 = PyFloat_FromDouble((__pyx_v_rule->cscores[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
+ __Pyx_GIVEREF(__pyx_t_4);
+ __pyx_t_4 = 0;
+ __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_n_s__PhraseModel_), __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ if (PyObject_SetItem(__pyx_v_scores, __pyx_t_5, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ }
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":34
+ * for i in range(rule.n_scores):
+ * scores['PhraseModel_'+str(i)] = rule.cscores[i]
+ * f, e = [], [] # <<<<<<<<<<<<<<
+ * cdef int* fsyms = rule.f.syms
+ * for i in range(rule.f.n):
+ */
+ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_v_f = __pyx_t_1;
+ __pyx_t_1 = 0;
+ __pyx_v_e = __pyx_t_5;
+ __pyx_t_5 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":35
+ * scores['PhraseModel_'+str(i)] = rule.cscores[i]
+ * f, e = [], []
+ * cdef int* fsyms = rule.f.syms # <<<<<<<<<<<<<<
+ * for i in range(rule.f.n):
+ * if _sa.sym_isvar(fsyms[i]):
+ */
+ __pyx_v_fsyms = __pyx_v_rule->f->syms;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":36
+ * f, e = [], []
+ * cdef int* fsyms = rule.f.syms
+ * for i in range(rule.f.n): # <<<<<<<<<<<<<<
+ * if _sa.sym_isvar(fsyms[i]):
+ * f.append(NT(_sa.sym_tocat(fsyms[i])))
+ */
+ __pyx_t_2 = __pyx_v_rule->f->n;
+ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
+ __pyx_v_i = __pyx_t_3;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":37
+ * cdef int* fsyms = rule.f.syms
+ * for i in range(rule.f.n):
+ * if _sa.sym_isvar(fsyms[i]): # <<<<<<<<<<<<<<
+ * f.append(NT(_sa.sym_tocat(fsyms[i])))
+ * else:
+ */
+ __pyx_t_6 = __pyx_f_4cdec_2sa_3_sa_sym_isvar((__pyx_v_fsyms[__pyx_v_i]));
+ if (__pyx_t_6) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":38
+ * for i in range(rule.f.n):
+ * if _sa.sym_isvar(fsyms[i]):
+ * f.append(NT(_sa.sym_tocat(fsyms[i]))) # <<<<<<<<<<<<<<
+ * else:
+ * f.append(_sa.sym_tostring(fsyms[i]))
+ */
+ __pyx_t_5 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tocat((__pyx_v_fsyms[__pyx_v_i]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_5));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
+ __pyx_t_5 = 0;
+ __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+ __pyx_t_7 = PyList_Append(__pyx_v_f, __pyx_t_5); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ goto __pyx_L7;
+ }
+ /*else*/ {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":40
+ * f.append(NT(_sa.sym_tocat(fsyms[i])))
+ * else:
+ * f.append(_sa.sym_tostring(fsyms[i])) # <<<<<<<<<<<<<<
+ * cdef int* esyms = rule.e.syms
+ * for i in range(rule.e.n):
+ */
+ __pyx_t_5 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tostring((__pyx_v_fsyms[__pyx_v_i]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+ __pyx_t_7 = PyList_Append(__pyx_v_f, ((PyObject *)__pyx_t_5)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ }
+ __pyx_L7:;
+ }
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":41
+ * else:
+ * f.append(_sa.sym_tostring(fsyms[i]))
+ * cdef int* esyms = rule.e.syms # <<<<<<<<<<<<<<
+ * for i in range(rule.e.n):
+ * if _sa.sym_isvar(esyms[i]):
+ */
+ __pyx_v_esyms = __pyx_v_rule->e->syms;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":42
+ * f.append(_sa.sym_tostring(fsyms[i]))
+ * cdef int* esyms = rule.e.syms
+ * for i in range(rule.e.n): # <<<<<<<<<<<<<<
+ * if _sa.sym_isvar(esyms[i]):
+ * e.append(NTRef(_sa.sym_getindex(esyms[i])))
+ */
+ __pyx_t_2 = __pyx_v_rule->e->n;
+ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
+ __pyx_v_i = __pyx_t_3;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":43
+ * cdef int* esyms = rule.e.syms
+ * for i in range(rule.e.n):
+ * if _sa.sym_isvar(esyms[i]): # <<<<<<<<<<<<<<
+ * e.append(NTRef(_sa.sym_getindex(esyms[i])))
+ * else:
+ */
+ __pyx_t_6 = __pyx_f_4cdec_2sa_3_sa_sym_isvar((__pyx_v_esyms[__pyx_v_i]));
+ if (__pyx_t_6) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":44
+ * for i in range(rule.e.n):
+ * if _sa.sym_isvar(esyms[i]):
+ * e.append(NTRef(_sa.sym_getindex(esyms[i]))) # <<<<<<<<<<<<<<
+ * else:
+ * e.append(_sa.sym_tostring(esyms[i]))
+ */
+ __pyx_t_5 = PyInt_FromLong(__pyx_f_4cdec_2sa_3_sa_sym_getindex((__pyx_v_esyms[__pyx_v_i]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
+ __Pyx_GIVEREF(__pyx_t_5);
+ __pyx_t_5 = 0;
+ __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+ __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_t_5); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ goto __pyx_L10;
+ }
+ /*else*/ {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":46
+ * e.append(NTRef(_sa.sym_getindex(esyms[i])))
+ * else:
+ * e.append(_sa.sym_tostring(esyms[i])) # <<<<<<<<<<<<<<
+ * cdef a = [(point/65536, point%65536) for point in rule.word_alignments]
+ * return TRule(lhs, f, e, scores, a)
+ */
+ __pyx_t_5 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tostring((__pyx_v_esyms[__pyx_v_i]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+ __pyx_t_7 = PyList_Append(__pyx_v_e, ((PyObject *)__pyx_t_5)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ }
+ __pyx_L10:;
+ }
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":47
+ * else:
+ * e.append(_sa.sym_tostring(esyms[i]))
+ * cdef a = [(point/65536, point%65536) for point in rule.word_alignments] # <<<<<<<<<<<<<<
+ * return TRule(lhs, f, e, scores, a)
+ *
+ */
+ __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ if (PyList_CheckExact(__pyx_v_rule->word_alignments) || PyTuple_CheckExact(__pyx_v_rule->word_alignments)) {
+ __pyx_t_1 = __pyx_v_rule->word_alignments; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0;
+ __pyx_t_9 = NULL;
+ } else {
+ __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rule->word_alignments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_9 = Py_TYPE(__pyx_t_1)->tp_iternext;
+ }
+ for (;;) {
+ if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++;
+ #else
+ __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++;
+ #else
+ __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_4 = __pyx_t_9(__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 = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_4);
+ }
+ __Pyx_XDECREF(__pyx_v_point);
+ __pyx_v_point = __pyx_t_4;
+ __pyx_t_4 = 0;
+ __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_v_point, __pyx_int_65536); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_t_10 = PyNumber_Remainder(__pyx_v_point, __pyx_int_65536); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_10);
+ __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_11);
+ PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4);
+ __Pyx_GIVEREF(__pyx_t_4);
+ PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10);
+ __Pyx_GIVEREF(__pyx_t_10);
+ __pyx_t_4 = 0;
+ __pyx_t_10 = 0;
+ if (unlikely(__Pyx_PyList_Append(__pyx_t_5, (PyObject*)__pyx_t_11))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
+ }
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_INCREF(((PyObject *)__pyx_t_5));
+ __pyx_v_a = ((PyObject *)__pyx_t_5);
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":48
+ * e.append(_sa.sym_tostring(esyms[i]))
+ * cdef a = [(point/65536, point%65536) for point in rule.word_alignments]
+ * return TRule(lhs, f, e, scores, a) # <<<<<<<<<<<<<<
+ *
+ * cdef class TRule:
+ */
+ __Pyx_XDECREF(((PyObject *)__pyx_r));
+ __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_INCREF(__pyx_v_lhs);
+ PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_lhs);
+ __Pyx_GIVEREF(__pyx_v_lhs);
+ __Pyx_INCREF(((PyObject *)__pyx_v_f));
+ PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_f));
+ __Pyx_GIVEREF(((PyObject *)__pyx_v_f));
+ __Pyx_INCREF(((PyObject *)__pyx_v_e));
+ PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)__pyx_v_e));
+ __Pyx_GIVEREF(((PyObject *)__pyx_v_e));
+ __Pyx_INCREF(__pyx_v_scores);
+ PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_scores);
+ __Pyx_GIVEREF(__pyx_v_scores);
+ __Pyx_INCREF(__pyx_v_a);
+ PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_v_a);
+ __Pyx_GIVEREF(__pyx_v_a);
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TRule)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ __pyx_r = ((struct __pyx_obj_5_cdec_TRule *)__pyx_t_1);
+ __pyx_t_1 = 0;
+ goto __pyx_L0;
+
+ __pyx_r = ((struct __pyx_obj_5_cdec_TRule *)Py_None); __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_XDECREF(__pyx_t_5);
+ __Pyx_XDECREF(__pyx_t_10);
+ __Pyx_XDECREF(__pyx_t_11);
+ __Pyx_AddTraceback("_cdec.convert_rule", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = 0;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_lhs);
+ __Pyx_XDECREF(__pyx_v_scores);
+ __Pyx_XDECREF(__pyx_v_f);
+ __Pyx_XDECREF(__pyx_v_e);
+ __Pyx_XDECREF(__pyx_v_a);
+ __Pyx_XDECREF(__pyx_v_point);
+ __Pyx_XGIVEREF((PyObject *)__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
/* Python wrapper */
-static void __pyx_pw_5_cdec_9BaseTRule_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pw_5_cdec_9BaseTRule_1__dealloc__(PyObject *__pyx_v_self) {
+static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ PyObject *__pyx_v_lhs = 0;
+ PyObject *__pyx_v_f = 0;
+ PyObject *__pyx_v_e = 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__f,&__pyx_n_s__e,&__pyx_n_s__scores,&__pyx_n_s__a,0};
+ PyObject* values[5] = {0,0,0,0,0};
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":53
+ * cdef shared_ptr[grammar.TRule]* rule
+ *
+ * def __init__(self, lhs, f, e, scores, a=None): # <<<<<<<<<<<<<<
+ * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule())
+ * self.lhs = lhs
+ */
+ values[4] = ((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 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+ 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__f)) != 0)) kw_args--;
+ else {
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ case 2:
+ if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__e)) != 0)) kw_args--;
+ else {
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ case 3:
+ if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scores)) != 0)) kw_args--;
+ else {
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ case 4:
+ if (kw_args > 0) {
+ PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__a);
+ if (value) { values[4] = 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 = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ } else {
+ switch (PyTuple_GET_SIZE(__pyx_args)) {
+ case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+ case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 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_f = values[1];
+ __pyx_v_e = values[2];
+ __pyx_v_scores = values[3];
+ __pyx_v_a = values[4];
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L5_argtuple_error:;
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("_cdec.TRule.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return -1;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_5TRule___init__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self), __pyx_v_lhs, __pyx_v_f, __pyx_v_e, __pyx_v_scores, __pyx_v_a);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static int __pyx_pf_5_cdec_5TRule___init__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_f, PyObject *__pyx_v_e, PyObject *__pyx_v_scores, PyObject *__pyx_v_a) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ TRule *__pyx_t_1;
+ int __pyx_t_2;
+ 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":54
+ *
+ * def __init__(self, lhs, f, e, scores, a=None):
+ * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule()) # <<<<<<<<<<<<<<
+ * self.lhs = lhs
+ * self.e = e
+ */
+ try {__pyx_t_1 = new TRule();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}}
+ __pyx_v_self->rule = new boost::shared_ptr<TRule>(__pyx_t_1);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":55
+ * def __init__(self, lhs, f, e, scores, a=None):
+ * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule())
+ * self.lhs = lhs # <<<<<<<<<<<<<<
+ * self.e = e
+ * self.f = f
+ */
+ if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__lhs, __pyx_v_lhs) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":56
+ * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule())
+ * self.lhs = lhs
+ * self.e = e # <<<<<<<<<<<<<<
+ * self.f = f
+ * self.scores = scores
+ */
+ if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__e, __pyx_v_e) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":57
+ * self.lhs = lhs
+ * self.e = e
+ * self.f = f # <<<<<<<<<<<<<<
+ * self.scores = scores
+ * if a:
+ */
+ if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__f, __pyx_v_f) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":58
+ * self.e = e
+ * self.f = f
+ * self.scores = scores # <<<<<<<<<<<<<<
+ * if a:
+ * self.a = a
+ */
+ if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__scores, __pyx_v_scores) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":59
+ * self.f = f
+ * self.scores = scores
+ * if a: # <<<<<<<<<<<<<<
+ * self.a = a
+ * self.rule.get().ComputeArity()
+ */
+ __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_a); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__pyx_t_2) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":60
+ * self.scores = scores
+ * if a:
+ * self.a = a # <<<<<<<<<<<<<<
+ * self.rule.get().ComputeArity()
+ *
+ */
+ if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__a, __pyx_v_a) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":61
+ * if a:
+ * self.a = a
+ * self.rule.get().ComputeArity() # <<<<<<<<<<<<<<
+ *
+ * def __dealloc__(self):
+ */
+ __pyx_v_self->rule->get()->ComputeArity();
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.TRule.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static void __pyx_pw_5_cdec_5TRule_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_5_cdec_5TRule_3__dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
- __pyx_pf_5_cdec_9BaseTRule___dealloc__(((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_self));
+ __pyx_pf_5_cdec_5TRule_2__dealloc__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":29
- * cdef shared_ptr[grammar.TRule]* rule
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":63
+ * self.rule.get().ComputeArity()
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
* del self.rule
*
*/
-static void __pyx_pf_5_cdec_9BaseTRule___dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self) {
+static void __pyx_pf_5_cdec_5TRule_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":30
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":64
*
* def __dealloc__(self):
* del self.rule # <<<<<<<<<<<<<<
@@ -5105,17 +6010,17 @@ static void __pyx_pf_5_cdec_9BaseTRule___dealloc__(CYTHON_UNUSED struct __pyx_ob
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_9BaseTRule_5arity_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_9BaseTRule_5arity_1__get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pw_5_cdec_5TRule_5arity_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5TRule_5arity_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_9BaseTRule_5arity___get__(((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_5TRule_5arity___get__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":33
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":67
*
* property arity:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -5123,7 +6028,7 @@ static PyObject *__pyx_pw_5_cdec_9BaseTRule_5arity_1__get__(PyObject *__pyx_v_se
*
*/
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_5arity___get__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_5TRule_5arity___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
@@ -5132,7 +6037,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_5arity___get__(struct __pyx_obj_5_cd
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":34
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":68
* property arity:
* def __get__(self):
* return self.rule.get().arity_ # <<<<<<<<<<<<<<
@@ -5140,7 +6045,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_5arity___get__(struct __pyx_obj_5_cd
* property f:
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyInt_FromLong(__pyx_v_self->rule->get()->arity_); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyInt_FromLong(__pyx_v_self->rule->get()->arity_); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -5150,7 +6055,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_5arity___get__(struct __pyx_obj_5_cd
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("_cdec.BaseTRule.arity.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.TRule.arity.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
@@ -5159,17 +6064,17 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_5arity___get__(struct __pyx_obj_5_cd
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_9BaseTRule_1f_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_9BaseTRule_1f_1__get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pw_5_cdec_5TRule_1f_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5TRule_1f_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_9BaseTRule_1f___get__(((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_5TRule_1f___get__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":37
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":71
*
* property f:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -5177,7 +6082,7 @@ static PyObject *__pyx_pw_5_cdec_9BaseTRule_1f_1__get__(PyObject *__pyx_v_self)
* cdef WordID w
*/
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_1f___get__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
std::vector<WordID> *__pyx_v_f_;
WordID __pyx_v_w;
PyObject *__pyx_v_f = 0;
@@ -5196,7 +6101,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1f___get__(struct __pyx_obj_5_cdec_B
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":38
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":72
* property f:
* def __get__(self):
* cdef vector[WordID]* f_ = &self.rule.get().f_ # <<<<<<<<<<<<<<
@@ -5205,19 +6110,19 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1f___get__(struct __pyx_obj_5_cdec_B
*/
__pyx_v_f_ = (&__pyx_v_self->rule->get()->f_);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":40
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":74
* cdef vector[WordID]* f_ = &self.rule.get().f_
* cdef WordID w
* cdef f = [] # <<<<<<<<<<<<<<
* cdef unsigned i
* cdef int idx = 0
*/
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_f = ((PyObject *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":42
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":76
* cdef f = []
* cdef unsigned i
* cdef int idx = 0 # <<<<<<<<<<<<<<
@@ -5226,7 +6131,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1f___get__(struct __pyx_obj_5_cdec_B
*/
__pyx_v_idx = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":43
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":77
* cdef unsigned i
* cdef int idx = 0
* for i in range(f_.size()): # <<<<<<<<<<<<<<
@@ -5237,7 +6142,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1f___get__(struct __pyx_obj_5_cdec_B
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":44
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":78
* cdef int idx = 0
* for i in range(f_.size()):
* w = f_[0][i] # <<<<<<<<<<<<<<
@@ -5246,7 +6151,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1f___get__(struct __pyx_obj_5_cdec_B
*/
__pyx_v_w = ((__pyx_v_f_[0])[__pyx_v_i]);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":45
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":79
* for i in range(f_.size()):
* w = f_[0][i]
* if w < 0: # <<<<<<<<<<<<<<
@@ -5256,7 +6161,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1f___get__(struct __pyx_obj_5_cdec_B
__pyx_t_4 = (__pyx_v_w < 0);
if (__pyx_t_4) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":46
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":80
* w = f_[0][i]
* if w < 0:
* idx += 1 # <<<<<<<<<<<<<<
@@ -5265,18 +6170,18 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1f___get__(struct __pyx_obj_5_cdec_B
*/
__pyx_v_idx = (__pyx_v_idx + 1);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":47
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":81
* if w < 0:
* idx += 1
* f.append(NT(TDConvert(-w), idx)) # <<<<<<<<<<<<<<
* else:
* f.append(unicode(TDConvert(w), encoding='utf8'))
*/
- __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_w))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_w))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
- __pyx_t_5 = PyInt_FromLong(__pyx_v_idx); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyInt_FromLong(__pyx_v_idx); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_1));
__Pyx_GIVEREF(((PyObject *)__pyx_t_1));
@@ -5284,10 +6189,10 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1f___get__(struct __pyx_obj_5_cdec_B
__Pyx_GIVEREF(__pyx_t_5);
__pyx_t_1 = 0;
__pyx_t_5 = 0;
- __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
- __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_f, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_f, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
@@ -5295,28 +6200,28 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1f___get__(struct __pyx_obj_5_cdec_B
}
/*else*/ {
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":49
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":83
* f.append(NT(TDConvert(-w), idx))
* else:
* f.append(unicode(TDConvert(w), encoding='utf8')) # <<<<<<<<<<<<<<
* return f
*
*/
- __pyx_t_6 = PyBytes_FromString(TD::Convert(__pyx_v_w)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyBytes_FromString(TD::Convert(__pyx_v_w)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_6));
- __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_6));
__Pyx_GIVEREF(((PyObject *)__pyx_t_6));
__pyx_t_6 = 0;
- __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_6));
- if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
- __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_f, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_f, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
@@ -5324,7 +6229,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1f___get__(struct __pyx_obj_5_cdec_B
__pyx_L5:;
}
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":50
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":84
* else:
* f.append(unicode(TDConvert(w), encoding='utf8'))
* return f # <<<<<<<<<<<<<<
@@ -5342,7 +6247,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1f___get__(struct __pyx_obj_5_cdec_B
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("_cdec.BaseTRule.f.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.TRule.f.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_f);
@@ -5352,17 +6257,17 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1f___get__(struct __pyx_obj_5_cdec_B
}
/* Python wrapper */
-static int __pyx_pw_5_cdec_9BaseTRule_1f_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
-static int __pyx_pw_5_cdec_9BaseTRule_1f_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
+static int __pyx_pw_5_cdec_5TRule_1f_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
+static int __pyx_pw_5_cdec_5TRule_1f_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_9BaseTRule_1f_2__set__(((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_self), ((PyObject *)__pyx_v_f));
+ __pyx_r = __pyx_pf_5_cdec_5TRule_1f_2__set__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self), ((PyObject *)__pyx_v_f));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":52
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":86
* return f
*
* def __set__(self, f): # <<<<<<<<<<<<<<
@@ -5370,7 +6275,7 @@ static int __pyx_pw_5_cdec_9BaseTRule_1f_3__set__(PyObject *__pyx_v_self, PyObje
* f_.resize(len(f))
*/
-static int __pyx_pf_5_cdec_9BaseTRule_1f_2__set__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self, PyObject *__pyx_v_f) {
+static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_f) {
std::vector<WordID> *__pyx_v_f_;
unsigned int __pyx_v_i;
CYTHON_UNUSED int __pyx_v_idx;
@@ -5387,7 +6292,7 @@ static int __pyx_pf_5_cdec_9BaseTRule_1f_2__set__(struct __pyx_obj_5_cdec_BaseTR
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__set__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":53
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":87
*
* def __set__(self, f):
* cdef vector[WordID]* f_ = &self.rule.get().f_ # <<<<<<<<<<<<<<
@@ -5396,17 +6301,17 @@ static int __pyx_pf_5_cdec_9BaseTRule_1f_2__set__(struct __pyx_obj_5_cdec_BaseTR
*/
__pyx_v_f_ = (&__pyx_v_self->rule->get()->f_);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":54
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":88
* def __set__(self, f):
* cdef vector[WordID]* f_ = &self.rule.get().f_
* f_.resize(len(f)) # <<<<<<<<<<<<<<
* cdef unsigned i
* cdef int idx = 0
*/
- __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_f_->resize(__pyx_t_1);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":56
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":90
* f_.resize(len(f))
* cdef unsigned i
* cdef int idx = 0 # <<<<<<<<<<<<<<
@@ -5415,25 +6320,25 @@ static int __pyx_pf_5_cdec_9BaseTRule_1f_2__set__(struct __pyx_obj_5_cdec_BaseTR
*/
__pyx_v_idx = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":57
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":91
* cdef unsigned i
* cdef int idx = 0
* for i in range(len(f)): # <<<<<<<<<<<<<<
* if isinstance(f[i], NT):
* f_[0][i] = -TDConvert(<char *>f[i].cat)
*/
- __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
__pyx_v_i = __pyx_t_2;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":58
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":92
* cdef int idx = 0
* for i in range(len(f)):
* if isinstance(f[i], NT): # <<<<<<<<<<<<<<
* f_[0][i] = -TDConvert(<char *>f[i].cat)
* else:
*/
- __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT));
__Pyx_INCREF(__pyx_t_4);
@@ -5442,33 +6347,33 @@ static int __pyx_pf_5_cdec_9BaseTRule_1f_2__set__(struct __pyx_obj_5_cdec_BaseTR
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
if (__pyx_t_5) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":59
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":93
* for i in range(len(f)):
* if isinstance(f[i], NT):
* f_[0][i] = -TDConvert(<char *>f[i].cat) # <<<<<<<<<<<<<<
* else:
* f_[0][i] = TDConvert(<char *>as_str(f[i]))
*/
- __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__cat); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__cat); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_6 = PyBytes_AsString(__pyx_t_3); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyBytes_AsString(__pyx_t_3); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
((__pyx_v_f_[0])[__pyx_v_i]) = (-TD::Convert(((char *)__pyx_t_6)));
goto __pyx_L5;
}
/*else*/ {
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":61
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":95
* f_[0][i] = -TDConvert(<char *>f[i].cat)
* else:
* f_[0][i] = TDConvert(<char *>as_str(f[i])) # <<<<<<<<<<<<<<
*
* property e:
*/
- __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
((__pyx_v_f_[0])[__pyx_v_i]) = TD::Convert(((char *)__pyx_f_5_cdec_as_str(__pyx_t_3, NULL)));
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
@@ -5481,7 +6386,7 @@ static int __pyx_pf_5_cdec_9BaseTRule_1f_2__set__(struct __pyx_obj_5_cdec_BaseTR
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("_cdec.BaseTRule.f.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.TRule.f.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
@@ -5489,17 +6394,17 @@ static int __pyx_pf_5_cdec_9BaseTRule_1f_2__set__(struct __pyx_obj_5_cdec_BaseTR
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_9BaseTRule_1e_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_9BaseTRule_1e_1__get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pw_5_cdec_5TRule_1e_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5TRule_1e_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_9BaseTRule_1e___get__(((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_5TRule_1e___get__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":64
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":98
*
* property e:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -5507,7 +6412,7 @@ static PyObject *__pyx_pw_5_cdec_9BaseTRule_1e_1__get__(PyObject *__pyx_v_self)
* cdef WordID w
*/
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_1e___get__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
std::vector<WordID> *__pyx_v_e_;
WordID __pyx_v_w;
PyObject *__pyx_v_e = 0;
@@ -5526,7 +6431,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1e___get__(struct __pyx_obj_5_cdec_B
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":65
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":99
* property e:
* def __get__(self):
* cdef vector[WordID]* e_ = &self.rule.get().e_ # <<<<<<<<<<<<<<
@@ -5535,19 +6440,19 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1e___get__(struct __pyx_obj_5_cdec_B
*/
__pyx_v_e_ = (&__pyx_v_self->rule->get()->e_);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":67
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":101
* cdef vector[WordID]* e_ = &self.rule.get().e_
* cdef WordID w
* cdef e = [] # <<<<<<<<<<<<<<
* cdef unsigned i
* cdef int idx = 0
*/
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_e = ((PyObject *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":69
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":103
* cdef e = []
* cdef unsigned i
* cdef int idx = 0 # <<<<<<<<<<<<<<
@@ -5556,7 +6461,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1e___get__(struct __pyx_obj_5_cdec_B
*/
__pyx_v_idx = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":70
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":104
* cdef unsigned i
* cdef int idx = 0
* for i in range(e_.size()): # <<<<<<<<<<<<<<
@@ -5567,7 +6472,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1e___get__(struct __pyx_obj_5_cdec_B
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":71
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":105
* cdef int idx = 0
* for i in range(e_.size()):
* w = e_[0][i] # <<<<<<<<<<<<<<
@@ -5576,7 +6481,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1e___get__(struct __pyx_obj_5_cdec_B
*/
__pyx_v_w = ((__pyx_v_e_[0])[__pyx_v_i]);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":72
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":106
* for i in range(e_.size()):
* w = e_[0][i]
* if w < 1: # <<<<<<<<<<<<<<
@@ -5586,7 +6491,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1e___get__(struct __pyx_obj_5_cdec_B
__pyx_t_4 = (__pyx_v_w < 1);
if (__pyx_t_4) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":73
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":107
* w = e_[0][i]
* if w < 1:
* idx += 1 # <<<<<<<<<<<<<<
@@ -5595,24 +6500,24 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1e___get__(struct __pyx_obj_5_cdec_B
*/
__pyx_v_idx = (__pyx_v_idx + 1);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":74
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":108
* if w < 1:
* idx += 1
* e.append(NTRef(1-w)) # <<<<<<<<<<<<<<
* else:
* e.append(unicode(TDConvert(w), encoding='utf8'))
*/
- __pyx_t_1 = PyInt_FromLong((1 - __pyx_v_w)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyInt_FromLong((1 - __pyx_v_w)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
- __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_e, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_e, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
@@ -5620,28 +6525,28 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1e___get__(struct __pyx_obj_5_cdec_B
}
/*else*/ {
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":76
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":110
* e.append(NTRef(1-w))
* else:
* e.append(unicode(TDConvert(w), encoding='utf8')) # <<<<<<<<<<<<<<
* return e
*
*/
- __pyx_t_5 = PyBytes_FromString(TD::Convert(__pyx_v_w)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyBytes_FromString(TD::Convert(__pyx_v_w)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_5));
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_5));
__Pyx_GIVEREF(((PyObject *)__pyx_t_5));
__pyx_t_5 = 0;
- __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_5));
- if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
- __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_e, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_e, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
@@ -5649,7 +6554,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1e___get__(struct __pyx_obj_5_cdec_B
__pyx_L5:;
}
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":77
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":111
* else:
* e.append(unicode(TDConvert(w), encoding='utf8'))
* return e # <<<<<<<<<<<<<<
@@ -5667,7 +6572,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1e___get__(struct __pyx_obj_5_cdec_B
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("_cdec.BaseTRule.e.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.TRule.e.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_e);
@@ -5677,17 +6582,17 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1e___get__(struct __pyx_obj_5_cdec_B
}
/* Python wrapper */
-static int __pyx_pw_5_cdec_9BaseTRule_1e_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_e); /*proto*/
-static int __pyx_pw_5_cdec_9BaseTRule_1e_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_e) {
+static int __pyx_pw_5_cdec_5TRule_1e_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_e); /*proto*/
+static int __pyx_pw_5_cdec_5TRule_1e_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_e) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_9BaseTRule_1e_2__set__(((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_self), ((PyObject *)__pyx_v_e));
+ __pyx_r = __pyx_pf_5_cdec_5TRule_1e_2__set__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self), ((PyObject *)__pyx_v_e));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":79
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":113
* return e
*
* def __set__(self, e): # <<<<<<<<<<<<<<
@@ -5695,7 +6600,7 @@ static int __pyx_pw_5_cdec_9BaseTRule_1e_3__set__(PyObject *__pyx_v_self, PyObje
* e_.resize(len(e))
*/
-static int __pyx_pf_5_cdec_9BaseTRule_1e_2__set__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self, PyObject *__pyx_v_e) {
+static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_e) {
std::vector<WordID> *__pyx_v_e_;
unsigned int __pyx_v_i;
int __pyx_r;
@@ -5711,7 +6616,7 @@ static int __pyx_pf_5_cdec_9BaseTRule_1e_2__set__(struct __pyx_obj_5_cdec_BaseTR
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__set__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":80
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":114
*
* def __set__(self, e):
* cdef vector[WordID]* e_ = &self.rule.get().e_ # <<<<<<<<<<<<<<
@@ -5720,35 +6625,35 @@ static int __pyx_pf_5_cdec_9BaseTRule_1e_2__set__(struct __pyx_obj_5_cdec_BaseTR
*/
__pyx_v_e_ = (&__pyx_v_self->rule->get()->e_);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":81
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":115
* def __set__(self, e):
* cdef vector[WordID]* e_ = &self.rule.get().e_
* e_.resize(len(e)) # <<<<<<<<<<<<<<
* cdef unsigned i
* for i in range(len(e)):
*/
- __pyx_t_1 = PyObject_Length(__pyx_v_e); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Length(__pyx_v_e); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_e_->resize(__pyx_t_1);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":83
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":117
* e_.resize(len(e))
* cdef unsigned i
* for i in range(len(e)): # <<<<<<<<<<<<<<
* if isinstance(e[i], NTRef):
* e_[0][i] = 1-e[i].ref
*/
- __pyx_t_1 = PyObject_Length(__pyx_v_e); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Length(__pyx_v_e); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
__pyx_v_i = __pyx_t_2;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":84
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":118
* cdef unsigned i
* for i in range(len(e)):
* if isinstance(e[i], NTRef): # <<<<<<<<<<<<<<
* e_[0][i] = 1-e[i].ref
* else:
*/
- __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef));
__Pyx_INCREF(__pyx_t_4);
@@ -5757,36 +6662,36 @@ static int __pyx_pf_5_cdec_9BaseTRule_1e_2__set__(struct __pyx_obj_5_cdec_BaseTR
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
if (__pyx_t_5) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":85
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":119
* for i in range(len(e)):
* if isinstance(e[i], NTRef):
* e_[0][i] = 1-e[i].ref # <<<<<<<<<<<<<<
* else:
* e_[0][i] = TDConvert(<char *>as_str(e[i]))
*/
- __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__ref); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__ref); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyNumber_Subtract(__pyx_int_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyNumber_Subtract(__pyx_int_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_6 = __Pyx_PyInt_from_py_WordID(__pyx_t_4); if (unlikely((__pyx_t_6 == (WordID)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = __Pyx_PyInt_from_py_WordID(__pyx_t_4); if (unlikely((__pyx_t_6 == (WordID)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
((__pyx_v_e_[0])[__pyx_v_i]) = __pyx_t_6;
goto __pyx_L5;
}
/*else*/ {
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":87
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":121
* e_[0][i] = 1-e[i].ref
* else:
* e_[0][i] = TDConvert(<char *>as_str(e[i])) # <<<<<<<<<<<<<<
*
* property a:
*/
- __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
((__pyx_v_e_[0])[__pyx_v_i]) = TD::Convert(((char *)__pyx_f_5_cdec_as_str(__pyx_t_4, NULL)));
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
@@ -5799,26 +6704,26 @@ static int __pyx_pf_5_cdec_9BaseTRule_1e_2__set__(struct __pyx_obj_5_cdec_BaseTR
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("_cdec.BaseTRule.e.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.TRule.e.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_9BaseTRule_1a_2generator2(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+static PyObject *__pyx_gb_5_cdec_5TRule_1a_2generator2(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_9BaseTRule_1a_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_9BaseTRule_1a_1__get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pw_5_cdec_5TRule_1a_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5TRule_1a_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_9BaseTRule_1a___get__(((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_5TRule_1a___get__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":90
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":124
*
* property a:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -5826,7 +6731,7 @@ static PyObject *__pyx_pw_5_cdec_9BaseTRule_1a_1__get__(PyObject *__pyx_v_self)
* cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_
*/
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_1a___get__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_5TRule_1a___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@@ -5844,7 +6749,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1a___get__(struct __pyx_obj_5_cdec_B
__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_9BaseTRule_1a_2generator2, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_5TRule_1a_2generator2, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -5853,7 +6758,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1a___get__(struct __pyx_obj_5_cdec_B
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
- __Pyx_AddTraceback("_cdec.BaseTRule.a.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.TRule.a.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_DECREF(((PyObject *)__pyx_cur_scope));
@@ -5862,7 +6767,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_1a___get__(struct __pyx_obj_5_cdec_B
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_9BaseTRule_1a_2generator2(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+static PyObject *__pyx_gb_5_cdec_5TRule_1a_2generator2(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *)__pyx_generator->closure);
PyObject *__pyx_r = NULL;
@@ -5881,9 +6786,9 @@ static PyObject *__pyx_gb_5_cdec_9BaseTRule_1a_2generator2(__pyx_GeneratorObject
return NULL;
}
__pyx_L3_first_run:;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":92
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":126
* def __get__(self):
* cdef unsigned i
* cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_ # <<<<<<<<<<<<<<
@@ -5892,7 +6797,7 @@ static PyObject *__pyx_gb_5_cdec_9BaseTRule_1a_2generator2(__pyx_GeneratorObject
*/
__pyx_cur_scope->__pyx_v_a = (&__pyx_cur_scope->__pyx_v_self->rule->get()->a_);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":93
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":127
* cdef unsigned i
* cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_
* for i in range(a.size()): # <<<<<<<<<<<<<<
@@ -5903,18 +6808,18 @@ static PyObject *__pyx_gb_5_cdec_9BaseTRule_1a_2generator2(__pyx_GeneratorObject
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":94
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":128
* cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_
* for i in range(a.size()):
* yield (a[0][i].s_, a[0][i].t_) # <<<<<<<<<<<<<<
*
* def __set__(self, a):
*/
- __pyx_t_3 = PyInt_FromLong(((__pyx_cur_scope->__pyx_v_a[0])[__pyx_cur_scope->__pyx_v_i]).s_); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyInt_FromLong(((__pyx_cur_scope->__pyx_v_a[0])[__pyx_cur_scope->__pyx_v_i]).s_); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = PyInt_FromLong(((__pyx_cur_scope->__pyx_v_a[0])[__pyx_cur_scope->__pyx_v_i]).t_); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyInt_FromLong(((__pyx_cur_scope->__pyx_v_a[0])[__pyx_cur_scope->__pyx_v_i]).t_); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
@@ -5934,7 +6839,7 @@ static PyObject *__pyx_gb_5_cdec_9BaseTRule_1a_2generator2(__pyx_GeneratorObject
__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 = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
@@ -5946,22 +6851,23 @@ static PyObject *__pyx_gb_5_cdec_9BaseTRule_1a_2generator2(__pyx_GeneratorObject
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
/* Python wrapper */
-static int __pyx_pw_5_cdec_9BaseTRule_1a_4__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_a); /*proto*/
-static int __pyx_pw_5_cdec_9BaseTRule_1a_4__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_a) {
+static int __pyx_pw_5_cdec_5TRule_1a_4__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_a); /*proto*/
+static int __pyx_pw_5_cdec_5TRule_1a_4__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_a) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_9BaseTRule_1a_3__set__(((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_self), ((PyObject *)__pyx_v_a));
+ __pyx_r = __pyx_pf_5_cdec_5TRule_1a_3__set__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self), ((PyObject *)__pyx_v_a));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":96
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":130
* yield (a[0][i].s_, a[0][i].t_)
*
* def __set__(self, a): # <<<<<<<<<<<<<<
@@ -5969,7 +6875,7 @@ static int __pyx_pw_5_cdec_9BaseTRule_1a_4__set__(PyObject *__pyx_v_self, PyObje
* a_.resize(len(a))
*/
-static int __pyx_pf_5_cdec_9BaseTRule_1a_3__set__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self, PyObject *__pyx_v_a) {
+static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_a) {
std::vector<AlignmentPoint> *__pyx_v_a_;
unsigned int __pyx_v_i;
int __pyx_v_s;
@@ -5990,7 +6896,7 @@ static int __pyx_pf_5_cdec_9BaseTRule_1a_3__set__(struct __pyx_obj_5_cdec_BaseTR
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__set__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":97
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":131
*
* def __set__(self, a):
* cdef vector[grammar.AlignmentPoint]* a_ = &self.rule.get().a_ # <<<<<<<<<<<<<<
@@ -5999,61 +6905,67 @@ static int __pyx_pf_5_cdec_9BaseTRule_1a_3__set__(struct __pyx_obj_5_cdec_BaseTR
*/
__pyx_v_a_ = (&__pyx_v_self->rule->get()->a_);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":98
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":132
* def __set__(self, a):
* cdef vector[grammar.AlignmentPoint]* a_ = &self.rule.get().a_
* a_.resize(len(a)) # <<<<<<<<<<<<<<
* cdef unsigned i
* cdef int s, t
*/
- __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_a_->resize(__pyx_t_1);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":101
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":135
* cdef unsigned i
* cdef int s, t
* for i in range(len(a)): # <<<<<<<<<<<<<<
* s, t = a[i]
* a_[0][i] = grammar.AlignmentPoint(s, t)
*/
- __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
__pyx_v_i = __pyx_t_2;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":102
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":136
* cdef int s, t
* for i in range(len(a)):
* s, t = a[i] # <<<<<<<<<<<<<<
* a_[0][i] = grammar.AlignmentPoint(s, t)
*
*/
- __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_a, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_a, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
PyObject* sequence = __pyx_t_3;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 2)) {
+ if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
- if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
- if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
- else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
__pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
} else {
- if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
- if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
- else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
__pyx_t_4 = PyList_GET_ITEM(sequence, 0);
__pyx_t_5 = PyList_GET_ITEM(sequence, 1);
}
__Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(__pyx_t_5);
+ #else
+ __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
+ } else
+ {
Py_ssize_t index = -1;
- __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
@@ -6061,24 +6973,25 @@ static int __pyx_pf_5_cdec_9BaseTRule_1a_3__set__(struct __pyx_obj_5_cdec_BaseTR
__Pyx_GOTREF(__pyx_t_4);
index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
__Pyx_GOTREF(__pyx_t_5);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = NULL;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
goto __pyx_L6_unpacking_done;
__pyx_L5_unpacking_failed:;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
- if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
- {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_L6_unpacking_done:;
}
- __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_v_s = __pyx_t_8;
__pyx_v_t = __pyx_t_9;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":103
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":137
* for i in range(len(a)):
* s, t = a[i]
* a_[0][i] = grammar.AlignmentPoint(s, t) # <<<<<<<<<<<<<<
@@ -6095,7 +7008,7 @@ static int __pyx_pf_5_cdec_9BaseTRule_1a_3__set__(struct __pyx_obj_5_cdec_BaseTR
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("_cdec.BaseTRule.a.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.TRule.a.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
@@ -6103,25 +7016,25 @@ static int __pyx_pf_5_cdec_9BaseTRule_1a_3__set__(struct __pyx_obj_5_cdec_BaseTR
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_9BaseTRule_6scores_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_9BaseTRule_6scores_1__get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pw_5_cdec_5TRule_6scores_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5TRule_6scores_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_9BaseTRule_6scores___get__(((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_5TRule_6scores___get__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":106
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":140
*
* property scores:
* def __get__(self): # <<<<<<<<<<<<<<
- * cdef SparseVector scores = SparseVector()
+ * cdef SparseVector scores = SparseVector.__new__(SparseVector)
* scores.vector = new FastSparseVector[double](self.rule.get().scores_)
*/
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_6scores___get__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_5TRule_6scores___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
struct __pyx_obj_5_cdec_SparseVector *__pyx_v_scores = 0;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@@ -6131,29 +7044,30 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_6scores___get__(struct __pyx_obj_5_c
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":107
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":141
* property scores:
* def __get__(self):
- * cdef SparseVector scores = SparseVector() # <<<<<<<<<<<<<<
+ * cdef SparseVector scores = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<<
* scores.vector = new FastSparseVector[double](self.rule.get().scores_)
* return scores
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_scores = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":108
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":142
* def __get__(self):
- * cdef SparseVector scores = SparseVector()
+ * cdef SparseVector scores = SparseVector.__new__(SparseVector)
* scores.vector = new FastSparseVector[double](self.rule.get().scores_) # <<<<<<<<<<<<<<
* return scores
*
*/
__pyx_v_scores->vector = new FastSparseVector<double>(__pyx_v_self->rule->get()->scores_);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":109
- * cdef SparseVector scores = SparseVector()
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":143
+ * cdef SparseVector scores = SparseVector.__new__(SparseVector)
* scores.vector = new FastSparseVector[double](self.rule.get().scores_)
* return scores # <<<<<<<<<<<<<<
*
@@ -6168,7 +7082,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_6scores___get__(struct __pyx_obj_5_c
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("_cdec.BaseTRule.scores.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.TRule.scores.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_scores);
@@ -6178,17 +7092,17 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_6scores___get__(struct __pyx_obj_5_c
}
/* Python wrapper */
-static int __pyx_pw_5_cdec_9BaseTRule_6scores_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_scores); /*proto*/
-static int __pyx_pw_5_cdec_9BaseTRule_6scores_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_scores) {
+static int __pyx_pw_5_cdec_5TRule_6scores_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_scores); /*proto*/
+static int __pyx_pw_5_cdec_5TRule_6scores_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_scores) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_9BaseTRule_6scores_2__set__(((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_self), ((PyObject *)__pyx_v_scores));
+ __pyx_r = __pyx_pf_5_cdec_5TRule_6scores_2__set__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self), ((PyObject *)__pyx_v_scores));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":111
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":145
* return scores
*
* def __set__(self, scores): # <<<<<<<<<<<<<<
@@ -6196,7 +7110,7 @@ static int __pyx_pw_5_cdec_9BaseTRule_6scores_3__set__(PyObject *__pyx_v_self, P
* scores_.clear()
*/
-static int __pyx_pf_5_cdec_9BaseTRule_6scores_2__set__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self, PyObject *__pyx_v_scores) {
+static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_scores) {
FastSparseVector<double> *__pyx_v_scores_;
int __pyx_v_fid;
float __pyx_v_fval;
@@ -6218,7 +7132,7 @@ static int __pyx_pf_5_cdec_9BaseTRule_6scores_2__set__(struct __pyx_obj_5_cdec_B
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__set__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":112
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":146
*
* def __set__(self, scores):
* cdef FastSparseVector[double]* scores_ = &self.rule.get().scores_ # <<<<<<<<<<<<<<
@@ -6227,7 +7141,7 @@ static int __pyx_pf_5_cdec_9BaseTRule_6scores_2__set__(struct __pyx_obj_5_cdec_B
*/
__pyx_v_scores_ = (&__pyx_v_self->rule->get()->scores_);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":113
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":147
* def __set__(self, scores):
* cdef FastSparseVector[double]* scores_ = &self.rule.get().scores_
* scores_.clear() # <<<<<<<<<<<<<<
@@ -6236,23 +7150,23 @@ static int __pyx_pf_5_cdec_9BaseTRule_6scores_2__set__(struct __pyx_obj_5_cdec_B
*/
__pyx_v_scores_->clear();
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":116
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":150
* cdef int fid
* cdef float fval
* for fname, fval in scores.items(): # <<<<<<<<<<<<<<
* fid = FDConvert(<char *>as_str(fname))
* if fid < 0: raise KeyError(fname)
*/
- __pyx_t_1 = PyObject_GetAttr(__pyx_v_scores, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_scores, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
__pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
__pyx_t_4 = NULL;
} else {
- __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
}
@@ -6260,16 +7174,24 @@ static int __pyx_pf_5_cdec_9BaseTRule_6scores_2__set__(struct __pyx_obj_5_cdec_B
for (;;) {
if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else {
__pyx_t_2 = __pyx_t_4(__pyx_t_1);
if (unlikely(!__pyx_t_2)) {
if (PyErr_Occurred()) {
if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
- else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
break;
}
@@ -6277,29 +7199,35 @@ static int __pyx_pf_5_cdec_9BaseTRule_6scores_2__set__(struct __pyx_obj_5_cdec_B
}
if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
PyObject* sequence = __pyx_t_2;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 2)) {
+ if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
- if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
- if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
- else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
__pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
} else {
- if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
- if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
- else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
__pyx_t_5 = PyList_GET_ITEM(sequence, 0);
__pyx_t_6 = PyList_GET_ITEM(sequence, 1);
}
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(__pyx_t_6);
+ #else
+ __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
+ } else
+ {
Py_ssize_t index = -1;
- __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
@@ -6307,24 +7235,25 @@ static int __pyx_pf_5_cdec_9BaseTRule_6scores_2__set__(struct __pyx_obj_5_cdec_B
__Pyx_GOTREF(__pyx_t_5);
index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
__Pyx_GOTREF(__pyx_t_6);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = NULL;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
goto __pyx_L6_unpacking_done;
__pyx_L5_unpacking_failed:;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
- if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
- {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_L6_unpacking_done:;
}
- __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_XDECREF(__pyx_v_fname);
__pyx_v_fname = __pyx_t_5;
__pyx_t_5 = 0;
__pyx_v_fval = __pyx_t_9;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":117
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":151
* cdef float fval
* for fname, fval in scores.items():
* fid = FDConvert(<char *>as_str(fname)) # <<<<<<<<<<<<<<
@@ -6333,7 +7262,7 @@ static int __pyx_pf_5_cdec_9BaseTRule_6scores_2__set__(struct __pyx_obj_5_cdec_B
*/
__pyx_v_fid = FD::Convert(((char *)__pyx_f_5_cdec_as_str(__pyx_v_fname, NULL)));
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":118
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":152
* for fname, fval in scores.items():
* fid = FDConvert(<char *>as_str(fname))
* if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<<
@@ -6342,22 +7271,22 @@ static int __pyx_pf_5_cdec_9BaseTRule_6scores_2__set__(struct __pyx_obj_5_cdec_B
*/
__pyx_t_10 = (__pyx_v_fid < 0);
if (__pyx_t_10) {
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(__pyx_v_fname);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_fname);
__Pyx_GIVEREF(__pyx_v_fname);
- __pyx_t_6 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
__Pyx_Raise(__pyx_t_6, 0, 0, 0);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- {__pyx_filename = __pyx_f[2]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[2]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L7;
}
__pyx_L7:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":119
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":153
* fid = FDConvert(<char *>as_str(fname))
* if fid < 0: raise KeyError(fname)
* scores_.set_value(fid, fval) # <<<<<<<<<<<<<<
@@ -6376,7 +7305,7 @@ static int __pyx_pf_5_cdec_9BaseTRule_6scores_2__set__(struct __pyx_obj_5_cdec_B
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("_cdec.BaseTRule.scores.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.TRule.scores.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_fname);
@@ -6385,17 +7314,17 @@ static int __pyx_pf_5_cdec_9BaseTRule_6scores_2__set__(struct __pyx_obj_5_cdec_B
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_9BaseTRule_3lhs_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_9BaseTRule_3lhs_1__get__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pw_5_cdec_5TRule_3lhs_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5TRule_3lhs_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_9BaseTRule_3lhs___get__(((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_5TRule_3lhs___get__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":122
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":156
*
* property lhs:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -6403,7 +7332,7 @@ static PyObject *__pyx_pw_5_cdec_9BaseTRule_3lhs_1__get__(PyObject *__pyx_v_self
*
*/
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_3lhs___get__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_5TRule_3lhs___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
@@ -6413,7 +7342,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_3lhs___get__(struct __pyx_obj_5_cdec
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":123
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":157
* property lhs:
* def __get__(self):
* return NT(TDConvert(-self.rule.get().lhs_)) # <<<<<<<<<<<<<<
@@ -6421,14 +7350,14 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_3lhs___get__(struct __pyx_obj_5_cdec
* def __set__(self, lhs):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_self->rule->get()->lhs_))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_self->rule->get()->lhs_))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
__Pyx_GIVEREF(((PyObject *)__pyx_t_1));
__pyx_t_1 = 0;
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
__pyx_r = __pyx_t_1;
@@ -6440,7 +7369,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_3lhs___get__(struct __pyx_obj_5_cdec
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("_cdec.BaseTRule.lhs.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.TRule.lhs.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
@@ -6449,17 +7378,17 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_3lhs___get__(struct __pyx_obj_5_cdec
}
/* Python wrapper */
-static int __pyx_pw_5_cdec_9BaseTRule_3lhs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_lhs); /*proto*/
-static int __pyx_pw_5_cdec_9BaseTRule_3lhs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_lhs) {
+static int __pyx_pw_5_cdec_5TRule_3lhs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_lhs); /*proto*/
+static int __pyx_pw_5_cdec_5TRule_3lhs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_lhs) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_9BaseTRule_3lhs_2__set__(((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_self), ((PyObject *)__pyx_v_lhs));
+ __pyx_r = __pyx_pf_5_cdec_5TRule_3lhs_2__set__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self), ((PyObject *)__pyx_v_lhs));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":125
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":159
* return NT(TDConvert(-self.rule.get().lhs_))
*
* def __set__(self, lhs): # <<<<<<<<<<<<<<
@@ -6467,7 +7396,7 @@ static int __pyx_pw_5_cdec_9BaseTRule_3lhs_3__set__(PyObject *__pyx_v_self, PyOb
* lhs = NT(lhs)
*/
-static int __pyx_pf_5_cdec_9BaseTRule_3lhs_2__set__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self, PyObject *__pyx_v_lhs) {
+static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_lhs) {
int __pyx_r;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
@@ -6481,7 +7410,7 @@ static int __pyx_pf_5_cdec_9BaseTRule_3lhs_2__set__(struct __pyx_obj_5_cdec_Base
__Pyx_RefNannySetupContext("__set__", 0);
__Pyx_INCREF(__pyx_v_lhs);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":126
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":160
*
* def __set__(self, lhs):
* if not isinstance(lhs, NT): # <<<<<<<<<<<<<<
@@ -6495,19 +7424,19 @@ static int __pyx_pf_5_cdec_9BaseTRule_3lhs_2__set__(struct __pyx_obj_5_cdec_Base
__pyx_t_3 = (!__pyx_t_2);
if (__pyx_t_3) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":127
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":161
* def __set__(self, lhs):
* if not isinstance(lhs, NT):
* lhs = NT(lhs) # <<<<<<<<<<<<<<
* self.rule.get().lhs_ = -TDConvert(<char *>lhs.cat)
*
*/
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__pyx_v_lhs);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_lhs);
__Pyx_GIVEREF(__pyx_v_lhs);
- __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_v_lhs);
@@ -6517,16 +7446,16 @@ static int __pyx_pf_5_cdec_9BaseTRule_3lhs_2__set__(struct __pyx_obj_5_cdec_Base
}
__pyx_L3:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":128
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":162
* if not isinstance(lhs, NT):
* lhs = NT(lhs)
* self.rule.get().lhs_ = -TDConvert(<char *>lhs.cat) # <<<<<<<<<<<<<<
*
* def __str__(self):
*/
- __pyx_t_4 = PyObject_GetAttr(__pyx_v_lhs, __pyx_n_s__cat); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyObject_GetAttr(__pyx_v_lhs, __pyx_n_s__cat); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_v_self->rule->get()->lhs_ = (-TD::Convert(((char *)__pyx_t_5)));
@@ -6535,7 +7464,7 @@ static int __pyx_pf_5_cdec_9BaseTRule_3lhs_2__set__(struct __pyx_obj_5_cdec_Base
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("_cdec.BaseTRule.lhs.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.TRule.lhs.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_lhs);
@@ -6544,18 +7473,18 @@ static int __pyx_pf_5_cdec_9BaseTRule_3lhs_2__set__(struct __pyx_obj_5_cdec_Base
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_9BaseTRule_3__str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_9BaseTRule_3__str__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pw_5_cdec_5TRule_5__str__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5TRule_5__str__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_9BaseTRule_2__str__(((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_5TRule_4__str__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_9BaseTRule_7__str___2generator18(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator18(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":131
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":165
*
* def __str__(self):
* scores = ' '.join('%s=%s' % feat for feat in self.scores) # <<<<<<<<<<<<<<
@@ -6563,7 +7492,7 @@ static PyObject *__pyx_gb_5_cdec_9BaseTRule_7__str___2generator18(__pyx_Generato
* _phrase(self.f), _phrase(self.e), scores)
*/
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_7__str___genexpr(PyObject *__pyx_self) {
+static PyObject *__pyx_pf_5_cdec_5TRule_7__str___genexpr(PyObject *__pyx_self) {
struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@@ -6581,7 +7510,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_7__str___genexpr(PyObject *__pyx_sel
__Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
{
- __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_9BaseTRule_7__str___2generator18, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_5TRule_7__str___2generator18, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -6590,7 +7519,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_7__str___genexpr(PyObject *__pyx_sel
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
- __Pyx_AddTraceback("_cdec.BaseTRule.__str__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.TRule.__str__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_DECREF(((PyObject *)__pyx_cur_scope));
@@ -6599,7 +7528,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_7__str___genexpr(PyObject *__pyx_sel
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_9BaseTRule_7__str___2generator18(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator18(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *)__pyx_generator->closure);
PyObject *__pyx_r = NULL;
@@ -6617,15 +7546,15 @@ static PyObject *__pyx_gb_5_cdec_9BaseTRule_7__str___2generator18(__pyx_Generato
return NULL;
}
__pyx_L3_first_run:;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
- __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self), __pyx_n_s__scores); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
+ __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self), __pyx_n_s__scores); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
__pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
__pyx_t_4 = NULL;
} else {
- __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
}
@@ -6633,16 +7562,24 @@ static PyObject *__pyx_gb_5_cdec_9BaseTRule_7__str___2generator18(__pyx_Generato
for (;;) {
if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
+ #else
+ __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
+ #else
+ __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else {
__pyx_t_1 = __pyx_t_4(__pyx_t_2);
if (unlikely(!__pyx_t_1)) {
if (PyErr_Occurred()) {
if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
- else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
break;
}
@@ -6653,7 +7590,7 @@ static PyObject *__pyx_gb_5_cdec_9BaseTRule_7__str___2generator18(__pyx_Generato
__Pyx_GIVEREF(__pyx_t_1);
__pyx_cur_scope->__pyx_v_feat = __pyx_t_1;
__pyx_t_1 = 0;
- __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), __pyx_cur_scope->__pyx_v_feat); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), __pyx_cur_scope->__pyx_v_feat); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
__pyx_r = ((PyObject *)__pyx_t_1);
__pyx_t_1 = 0;
@@ -6672,7 +7609,7 @@ static PyObject *__pyx_gb_5_cdec_9BaseTRule_7__str___2generator18(__pyx_Generato
__Pyx_XGOTREF(__pyx_t_2);
__pyx_t_3 = __pyx_cur_scope->__pyx_t_1;
__pyx_t_4 = __pyx_cur_scope->__pyx_t_2;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
PyErr_SetNone(PyExc_StopIteration);
@@ -6684,11 +7621,12 @@ static PyObject *__pyx_gb_5_cdec_9BaseTRule_7__str___2generator18(__pyx_Generato
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":130
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":164
* self.rule.get().lhs_ = -TDConvert(<char *>lhs.cat)
*
* def __str__(self): # <<<<<<<<<<<<<<
@@ -6696,7 +7634,7 @@ static PyObject *__pyx_gb_5_cdec_9BaseTRule_7__str___2generator18(__pyx_Generato
* return '%s ||| %s ||| %s ||| %s' % (self.lhs,
*/
-static PyObject *__pyx_pf_5_cdec_9BaseTRule_2__str__(struct __pyx_obj_5_cdec_BaseTRule *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *__pyx_cur_scope;
PyObject *__pyx_v_scores = NULL;
PyObject *__pyx_r = NULL;
@@ -6720,30 +7658,30 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_2__str__(struct __pyx_obj_5_cdec_Bas
__Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
__Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":131
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":165
*
* def __str__(self):
* scores = ' '.join('%s=%s' % feat for feat in self.scores) # <<<<<<<<<<<<<<
* return '%s ||| %s ||| %s ||| %s' % (self.lhs,
* _phrase(self.f), _phrase(self.e), scores)
*/
- __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_7), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_7), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __pyx_pf_5_cdec_9BaseTRule_7__str___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = __pyx_pf_5_cdec_5TRule_7__str___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
__Pyx_GIVEREF(__pyx_t_2);
__pyx_t_2 = 0;
- __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
__pyx_v_scores = __pyx_t_2;
__pyx_t_2 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":132
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":166
* def __str__(self):
* scores = ' '.join('%s=%s' % feat for feat in self.scores)
* return '%s ||| %s ||| %s ||| %s' % (self.lhs, # <<<<<<<<<<<<<<
@@ -6751,43 +7689,43 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_2__str__(struct __pyx_obj_5_cdec_Bas
*
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__lhs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__lhs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":133
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":167
* scores = ' '.join('%s=%s' % feat for feat in self.scores)
* return '%s ||| %s ||| %s ||| %s' % (self.lhs,
* _phrase(self.f), _phrase(self.e), scores) # <<<<<<<<<<<<<<
*
- * cdef class TRule(BaseTRule):
+ * cdef class Grammar:
*/
- __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __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);
- __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__f); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__f); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
- __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__e); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__e); 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);
- __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_3 = 0;
- __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); 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);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
- __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
__Pyx_GIVEREF(__pyx_t_2);
@@ -6801,7 +7739,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_2__str__(struct __pyx_obj_5_cdec_Bas
__pyx_t_2 = 0;
__pyx_t_1 = 0;
__pyx_t_3 = 0;
- __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
__pyx_r = ((PyObject *)__pyx_t_3);
@@ -6816,7 +7754,7 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_2__str__(struct __pyx_obj_5_cdec_Bas
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("_cdec.BaseTRule.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.TRule.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_scores);
@@ -6827,199 +7765,6 @@ static PyObject *__pyx_pf_5_cdec_9BaseTRule_2__str__(struct __pyx_obj_5_cdec_Bas
}
/* Python wrapper */
-static int __pyx_pw_5_cdec_5TRule_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_5_cdec_5TRule_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_lhs = 0;
- PyObject *__pyx_v_f = 0;
- PyObject *__pyx_v_e = 0;
- PyObject *__pyx_v_scores = 0;
- PyObject *__pyx_v_a = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__lhs,&__pyx_n_s__f,&__pyx_n_s__e,&__pyx_n_s__scores,&__pyx_n_s__a,0};
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- PyObject* values[5] = {0,0,0,0,0};
-
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":136
- *
- * cdef class TRule(BaseTRule):
- * def __cinit__(self, lhs, f, e, scores, a=None): # <<<<<<<<<<<<<<
- * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule())
- * self.lhs = lhs
- */
- values[4] = ((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 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- 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:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lhs);
- if (likely(values[0])) kw_args--;
- else goto __pyx_L5_argtuple_error;
- case 1:
- values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__f);
- if (likely(values[1])) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
- }
- case 2:
- values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__e);
- if (likely(values[2])) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
- }
- case 3:
- values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scores);
- if (likely(values[3])) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
- }
- case 4:
- if (kw_args > 0) {
- PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__a);
- if (value) { values[4] = value; kw_args--; }
- }
- }
- 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 = 136; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 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_f = values[1];
- __pyx_v_e = values[2];
- __pyx_v_scores = values[3];
- __pyx_v_a = values[4];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
- __pyx_L3_error:;
- __Pyx_AddTraceback("_cdec.TRule.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5_cdec_5TRule___cinit__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self), __pyx_v_lhs, __pyx_v_f, __pyx_v_e, __pyx_v_scores, __pyx_v_a);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_5_cdec_5TRule___cinit__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_f, PyObject *__pyx_v_e, PyObject *__pyx_v_scores, PyObject *__pyx_v_a) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__cinit__", 0);
-
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":137
- * cdef class TRule(BaseTRule):
- * def __cinit__(self, lhs, f, e, scores, a=None):
- * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule()) # <<<<<<<<<<<<<<
- * self.lhs = lhs
- * self.e = e
- */
- __pyx_v_self->__pyx_base.rule = new boost::shared_ptr<TRule>(new TRule());
-
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":138
- * def __cinit__(self, lhs, f, e, scores, a=None):
- * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule())
- * self.lhs = lhs # <<<<<<<<<<<<<<
- * self.e = e
- * self.f = f
- */
- if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__lhs, __pyx_v_lhs) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":139
- * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule())
- * self.lhs = lhs
- * self.e = e # <<<<<<<<<<<<<<
- * self.f = f
- * self.scores = scores
- */
- if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__e, __pyx_v_e) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":140
- * self.lhs = lhs
- * self.e = e
- * self.f = f # <<<<<<<<<<<<<<
- * self.scores = scores
- * if a:
- */
- if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__f, __pyx_v_f) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":141
- * self.e = e
- * self.f = f
- * self.scores = scores # <<<<<<<<<<<<<<
- * if a:
- * self.a = a
- */
- if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__scores, __pyx_v_scores) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":142
- * self.f = f
- * self.scores = scores
- * if a: # <<<<<<<<<<<<<<
- * self.a = a
- * self.rule.get().ComputeArity()
- */
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_a); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__pyx_t_1) {
-
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":143
- * self.scores = scores
- * if a:
- * self.a = a # <<<<<<<<<<<<<<
- * self.rule.get().ComputeArity()
- *
- */
- if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__a, __pyx_v_a) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- goto __pyx_L3;
- }
- __pyx_L3:;
-
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":144
- * if a:
- * self.a = a
- * self.rule.get().ComputeArity() # <<<<<<<<<<<<<<
- *
- * cdef class Grammar:
- */
- __pyx_v_self->__pyx_base.rule->get()->ComputeArity();
-
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("_cdec.TRule.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __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
@@ -7028,7 +7773,7 @@ static void __pyx_pw_5_cdec_7Grammar_1__dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannyFinishContext();
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":149
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":172
* cdef shared_ptr[grammar.Grammar]* grammar
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
@@ -7040,7 +7785,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":150
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":173
*
* def __dealloc__(self):
* del self.grammar # <<<<<<<<<<<<<<
@@ -7064,12 +7809,12 @@ static PyObject *__pyx_pw_5_cdec_7Grammar_3__iter__(PyObject *__pyx_v_self) {
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":152
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":175
* del self.grammar
*
* def __iter__(self): # <<<<<<<<<<<<<<
- * cdef grammar.GrammarIter* root = self.grammar.get().GetRoot()
- * cdef grammar.RuleBin* rbin = root.GetRules()
+ * cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot()
+ * cdef grammar.const_RuleBin* rbin = root.GetRules()
*/
static PyObject *__pyx_pf_5_cdec_7Grammar_2__iter__(struct __pyx_obj_5_cdec_Grammar *__pyx_v_self) {
@@ -7090,7 +7835,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 = 152; __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 = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -7125,63 +7870,64 @@ 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 = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":153
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":176
*
* def __iter__(self):
- * cdef grammar.GrammarIter* root = self.grammar.get().GetRoot() # <<<<<<<<<<<<<<
- * cdef grammar.RuleBin* rbin = root.GetRules()
+ * cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot() # <<<<<<<<<<<<<<
+ * cdef grammar.const_RuleBin* rbin = root.GetRules()
* cdef TRule trule
*/
__pyx_cur_scope->__pyx_v_root = __pyx_cur_scope->__pyx_v_self->grammar->get()->GetRoot();
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":154
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":177
* def __iter__(self):
- * cdef grammar.GrammarIter* root = self.grammar.get().GetRoot()
- * cdef grammar.RuleBin* rbin = root.GetRules() # <<<<<<<<<<<<<<
+ * cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot()
+ * cdef grammar.const_RuleBin* rbin = root.GetRules() # <<<<<<<<<<<<<<
* cdef TRule trule
* cdef unsigned i
*/
__pyx_cur_scope->__pyx_v_rbin = __pyx_cur_scope->__pyx_v_root->GetRules();
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":157
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":180
* cdef TRule trule
* cdef unsigned i
* for i in range(rbin.GetNumRules()): # <<<<<<<<<<<<<<
- * trule = TRule()
+ * trule = TRule.__new__(TRule)
* trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i))
*/
__pyx_t_1 = __pyx_cur_scope->__pyx_v_rbin->GetNumRules();
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":158
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":181
* cdef unsigned i
* for i in range(rbin.GetNumRules()):
- * trule = TRule() # <<<<<<<<<<<<<<
+ * trule = TRule.__new__(TRule) # <<<<<<<<<<<<<<
* trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i))
* yield trule
*/
- __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TRule)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 158; __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 = 181; __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;}
__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":159
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":182
* for i in range(rbin.GetNumRules()):
- * trule = TRule()
+ * trule = TRule.__new__(TRule)
* trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i)) # <<<<<<<<<<<<<<
* yield trule
*
*/
- __pyx_cur_scope->__pyx_v_trule->__pyx_base.rule = new boost::shared_ptr<TRule>(__pyx_cur_scope->__pyx_v_rbin->GetIthRule(__pyx_cur_scope->__pyx_v_i));
+ __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":160
- * trule = TRule()
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":183
+ * trule = TRule.__new__(TRule)
* trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i))
* yield trule # <<<<<<<<<<<<<<
*
@@ -7199,7 +7945,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 = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
@@ -7209,6 +7955,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
@@ -7224,7 +7971,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":163
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":186
*
* property name:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -7237,7 +7984,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":164
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":187
* property name:
* def __get__(self):
* self.grammar.get().GetGrammarName().c_str() # <<<<<<<<<<<<<<
@@ -7263,7 +8010,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":166
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":189
* self.grammar.get().GetGrammarName().c_str()
*
* def __set__(self, name): # <<<<<<<<<<<<<<
@@ -7280,14 +8027,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":167
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":190
*
* 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 = 167; __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 = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_self->grammar->get()->SetGrammarName(std::string(((char *)__pyx_t_1)));
__pyx_r = 0;
@@ -7304,11 +8051,11 @@ static int __pyx_pf_5_cdec_7Grammar_4name_2__set__(struct __pyx_obj_5_cdec_Gramm
static int __pyx_pw_5_cdec_11TextGrammar_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5_cdec_11TextGrammar_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_rules = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__rules,0};
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
{
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__rules,0};
PyObject* values[1] = {0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
@@ -7321,12 +8068,11 @@ static int __pyx_pw_5_cdec_11TextGrammar_1__cinit__(PyObject *__pyx_v_self, PyOb
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__rules);
- if (likely(values[0])) kw_args--;
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__rules)) != 0)) kw_args--;
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 = 170; __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 = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
goto __pyx_L5_argtuple_error;
@@ -7337,7 +8083,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 = 170; __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 = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("_cdec.TextGrammar.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
@@ -7348,7 +8094,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":170
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":193
*
* cdef class TextGrammar(Grammar):
* def __cinit__(self, rules): # <<<<<<<<<<<<<<
@@ -7366,13 +8112,14 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG
PyObject *(*__pyx_t_3)(PyObject *);
PyObject *__pyx_t_4 = NULL;
int __pyx_t_5;
- int __pyx_t_6;
+ PyObject *__pyx_t_6 = NULL;
+ int __pyx_t_7;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__cinit__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":171
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":194
* cdef class TextGrammar(Grammar):
* def __cinit__(self, rules):
* self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) # <<<<<<<<<<<<<<
@@ -7381,43 +8128,51 @@ 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":172
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":195
* def __cinit__(self, rules):
* self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar())
* cdef grammar.TextGrammar* _g = <grammar.TextGrammar*> self.grammar.get() # <<<<<<<<<<<<<<
* for trule in rules:
- * if not isinstance(trule, BaseTRule):
+ * if isinstance(trule, _sa.Rule):
*/
__pyx_v__g = ((TextGrammar *)__pyx_v_self->__pyx_base.grammar->get());
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":173
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":196
* self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar())
* cdef grammar.TextGrammar* _g = <grammar.TextGrammar*> self.grammar.get()
* for trule in rules: # <<<<<<<<<<<<<<
- * if not isinstance(trule, BaseTRule):
- * raise ValueError('the grammar should contain TRule objects')
+ * if isinstance(trule, _sa.Rule):
+ * trule = convert_rule(trule)
*/
if (PyList_CheckExact(__pyx_v_rules) || PyTuple_CheckExact(__pyx_v_rules)) {
__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 = 173; __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 = 196; __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 = 196; __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;};
+ #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;}
+ else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
break;
}
@@ -7427,41 +8182,73 @@ 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":174
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":197
* cdef grammar.TextGrammar* _g = <grammar.TextGrammar*> self.grammar.get()
* for trule in rules:
- * if not isinstance(trule, BaseTRule): # <<<<<<<<<<<<<<
- * raise ValueError('the grammar should contain TRule objects')
- * _g.AddRule((<BaseTRule> trule).rule[0])
+ * if isinstance(trule, _sa.Rule): # <<<<<<<<<<<<<<
+ * trule = convert_rule(trule)
+ * elif not isinstance(trule, TRule):
*/
- __pyx_t_4 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_BaseTRule));
+ __pyx_t_4 = ((PyObject *)((PyObject*)__pyx_ptype_4cdec_2sa_3_sa_Rule));
__Pyx_INCREF(__pyx_t_4);
__pyx_t_5 = __Pyx_TypeCheck(__pyx_v_trule, __pyx_t_4);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_6 = (!__pyx_t_5);
- if (__pyx_t_6) {
+ if (__pyx_t_5) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":175
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":198
* for trule in rules:
- * if not isinstance(trule, BaseTRule):
- * raise ValueError('the grammar should contain TRule objects') # <<<<<<<<<<<<<<
- * _g.AddRule((<BaseTRule> trule).rule[0])
+ * if isinstance(trule, _sa.Rule):
+ * trule = convert_rule(trule) # <<<<<<<<<<<<<<
+ * elif not isinstance(trule, TRule):
+ * raise ValueError('the grammar should contain TRule objects')
*/
- __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_14), 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_Raise(__pyx_t_4, 0, 0, 0);
+ 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;}
+ __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_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_v_trule);
+ __pyx_v_trule = __pyx_t_6;
+ __pyx_t_6 = 0;
+ goto __pyx_L5;
+ }
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":199
+ * if isinstance(trule, _sa.Rule):
+ * 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 *)((PyObject*)__pyx_ptype_5_cdec_TRule));
+ __Pyx_INCREF(__pyx_t_6);
+ __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_trule, __pyx_t_6);
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __pyx_t_7 = (!__pyx_t_5);
+ if (__pyx_t_7) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":200
+ * 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_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;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":176
- * if not isinstance(trule, BaseTRule):
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":201
+ * elif not isinstance(trule, TRule):
* raise ValueError('the grammar should contain TRule objects')
- * _g.AddRule((<BaseTRule> trule).rule[0]) # <<<<<<<<<<<<<<
+ * _g.AddRule((<TRule> trule).rule[0]) # <<<<<<<<<<<<<<
*/
- __pyx_v__g->AddRule((((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_trule)->rule[0]));
+ __pyx_v__g->AddRule((((struct __pyx_obj_5_cdec_TRule *)__pyx_v_trule)->rule[0]));
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -7470,6 +8257,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_4);
+ __Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("_cdec.TextGrammar.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
@@ -7738,7 +8526,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_7viterbi_features(PyObject *__pyx_
* return (f_tree, e_tree)
*
* def viterbi_features(self): # <<<<<<<<<<<<<<
- * cdef SparseVector fmap = SparseVector()
+ * cdef SparseVector fmap = SparseVector.__new__(SparseVector)
* fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0]))
*/
@@ -7755,18 +8543,19 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6viterbi_features(struct __pyx_obj
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":24
*
* def viterbi_features(self):
- * cdef SparseVector fmap = SparseVector() # <<<<<<<<<<<<<<
+ * cdef SparseVector fmap = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<<
* fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0]))
* return fmap
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_fmap = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":25
* def viterbi_features(self):
- * cdef SparseVector fmap = SparseVector()
+ * cdef SparseVector fmap = SparseVector.__new__(SparseVector)
* fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0])) # <<<<<<<<<<<<<<
* return fmap
*
@@ -7774,7 +8563,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6viterbi_features(struct __pyx_obj
__pyx_v_fmap->vector = new FastSparseVector<weight_t>(ViterbiFeatures((__pyx_v_self->hg[0])));
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":26
- * cdef SparseVector fmap = SparseVector()
+ * cdef SparseVector fmap = SparseVector.__new__(SparseVector)
* fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0]))
* return fmap # <<<<<<<<<<<<<<
*
@@ -8078,6 +8867,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
@@ -8378,6 +9168,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
@@ -8496,7 +9287,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject
* for k in range(size):
* derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) # <<<<<<<<<<<<<<
* if not derivation: break
- * fmap = SparseVector()
+ * fmap = SparseVector.__new__(SparseVector)
*/
__pyx_cur_scope->__pyx_v_derivation = __pyx_cur_scope->__pyx_v_derivations->LazyKthBest((__pyx_cur_scope->__pyx_v_self->hg->nodes_.size() - 1), __pyx_cur_scope->__pyx_v_k);
@@ -8504,7 +9295,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject
* for k in range(size):
* derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k)
* if not derivation: break # <<<<<<<<<<<<<<
- * fmap = SparseVector()
+ * fmap = SparseVector.__new__(SparseVector)
* fmap.vector = new FastSparseVector[weight_t](derivation._yield)
*/
__pyx_t_3 = (!(__pyx_cur_scope->__pyx_v_derivation != 0));
@@ -8517,12 +9308,13 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":70
* derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k)
* if not derivation: break
- * fmap = SparseVector() # <<<<<<<<<<<<<<
+ * fmap = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<<
* fmap.vector = new FastSparseVector[weight_t](derivation._yield)
* yield fmap
*/
- __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L5;}
+ __pyx_t_4 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L5;}
__Pyx_GOTREF(__pyx_t_4);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L5;}
__Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_fmap));
__Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_fmap));
__Pyx_GIVEREF(__pyx_t_4);
@@ -8531,7 +9323,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":71
* if not derivation: break
- * fmap = SparseVector()
+ * fmap = SparseVector.__new__(SparseVector)
* fmap.vector = new FastSparseVector[weight_t](derivation._yield) # <<<<<<<<<<<<<<
* yield fmap
* finally:
@@ -8539,7 +9331,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject
__pyx_cur_scope->__pyx_v_fmap->vector = new FastSparseVector<weight_t>(__pyx_cur_scope->__pyx_v_derivation->yield);
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":72
- * fmap = SparseVector()
+ * fmap = SparseVector.__new__(SparseVector)
* fmap.vector = new FastSparseVector[weight_t](derivation._yield)
* yield fmap # <<<<<<<<<<<<<<
* finally:
@@ -8603,6 +9395,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
@@ -8679,10 +9472,11 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject
struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *)__pyx_generator->closure);
PyObject *__pyx_r = NULL;
int __pyx_t_1;
- size_t __pyx_t_2;
- unsigned int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
+ MT19937 *__pyx_t_2;
+ size_t __pyx_t_3;
+ unsigned int __pyx_t_4;
PyObject *__pyx_t_5 = NULL;
+ PyObject *__pyx_t_6 = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("None", 0);
switch (__pyx_generator->resume_label) {
@@ -8721,7 +9515,8 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject
* hypergraph.sample_hypotheses(self.hg[0], n, self.rng, hypos)
* cdef unsigned k
*/
- __pyx_cur_scope->__pyx_v_self->rng = new MT19937();
+ try {__pyx_t_2 = new MT19937();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}}
+ __pyx_cur_scope->__pyx_v_self->rng = __pyx_t_2;
goto __pyx_L4;
}
__pyx_L4:;
@@ -8751,9 +9546,9 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject
* yield unicode(GetString(hypos[0][k].words).c_str(), 'utf8')
* finally:
*/
- __pyx_t_2 = __pyx_cur_scope->__pyx_v_hypos->size();
- for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
- __pyx_cur_scope->__pyx_v_k = __pyx_t_3;
+ __pyx_t_3 = __pyx_cur_scope->__pyx_v_hypos->size();
+ for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
+ __pyx_cur_scope->__pyx_v_k = __pyx_t_4;
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":84
* try:
@@ -8762,31 +9557,31 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject
* finally:
* del hypos
*/
- __pyx_t_4 = PyBytes_FromString(TD::GetString(((__pyx_cur_scope->__pyx_v_hypos[0])[__pyx_cur_scope->__pyx_v_k]).words).c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L6;}
- __Pyx_GOTREF(((PyObject *)__pyx_t_4));
- __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L6;}
- __Pyx_GOTREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
- __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
+ __pyx_t_5 = PyBytes_FromString(TD::GetString(((__pyx_cur_scope->__pyx_v_hypos[0])[__pyx_cur_scope->__pyx_v_k]).words).c_str()); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L6;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+ __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L6;}
+ __Pyx_GOTREF(__pyx_t_6);
+ PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
__Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
- PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s__utf8));
+ PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_n_s__utf8));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
- __pyx_t_4 = 0;
- __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L6;}
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
- __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
+ __pyx_t_5 = 0;
+ __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L6;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+ __pyx_r = __pyx_t_5;
+ __pyx_t_5 = 0;
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
/* return from generator, yielding value */
__pyx_generator->resume_label = 1;
return __pyx_r;
__pyx_L10_resume_from_yield:;
- __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
- __pyx_t_3 = __pyx_cur_scope->__pyx_t_1;
+ __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
+ __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L6;}
}
}
@@ -8806,8 +9601,8 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject
__pyx_why = 0; goto __pyx_L7;
__pyx_L6: {
__pyx_why = 4;
+ __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
__pyx_exc_lineno = __pyx_lineno;
goto __pyx_L7;
@@ -8828,12 +9623,13 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
__pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
+ __Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
@@ -8903,13 +9699,13 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_25prune(PyObject *__pyx_v_self, Py
PyObject *__pyx_v_beam_alpha = 0;
PyObject *__pyx_v_density = 0;
PyObject *__pyx_v_kwargs = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__beam_alpha,&__pyx_n_s__density,0};
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("prune (wrapper)", 0);
__pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
__Pyx_GOTREF(__pyx_v_kwargs);
{
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__beam_alpha,&__pyx_n_s__density,0};
PyObject* values[2] = {0,0};
values[0] = ((PyObject *)__pyx_int_0);
values[1] = ((PyObject *)__pyx_int_0);
@@ -9408,6 +10204,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator8(__pyx_Generator
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
@@ -9534,6 +10331,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator9(__pyx_Generator
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
@@ -9666,15 +10464,15 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_31inside_outside(PyObject *__pyx_v
* return self.hg.NumberOfPaths()
*
* def inside_outside(self): # <<<<<<<<<<<<<<
- * cdef FastSparseVector[LogVal[double]]* result = new FastSparseVector[LogVal[double]]()
- * cdef LogVal[double] z = hypergraph.InsideOutside(self.hg[0], result)
+ * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]()
+ * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result)
*/
static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) {
- FastSparseVector<LogVal<double> > *__pyx_v_result;
- LogVal<double> __pyx_v_z;
+ FastSparseVector<prob_t> *__pyx_v_result;
+ prob_t __pyx_v_z;
struct __pyx_obj_5_cdec_SparseVector *__pyx_v_vector = 0;
- FastSparseVector<LogVal<double> >::const_iterator *__pyx_v_it;
+ FastSparseVector<prob_t>::const_iterator *__pyx_v_it;
CYTHON_UNUSED unsigned int __pyx_v_i;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@@ -9689,62 +10487,63 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":133
*
* def inside_outside(self):
- * cdef FastSparseVector[LogVal[double]]* result = new FastSparseVector[LogVal[double]]() # <<<<<<<<<<<<<<
- * cdef LogVal[double] z = hypergraph.InsideOutside(self.hg[0], result)
+ * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]() # <<<<<<<<<<<<<<
+ * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result)
* result[0] /= z
*/
- __pyx_v_result = new FastSparseVector<LogVal<double> >();
+ __pyx_v_result = new FastSparseVector<prob_t>();
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":134
* def inside_outside(self):
- * cdef FastSparseVector[LogVal[double]]* result = new FastSparseVector[LogVal[double]]()
- * cdef LogVal[double] z = hypergraph.InsideOutside(self.hg[0], result) # <<<<<<<<<<<<<<
+ * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]()
+ * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) # <<<<<<<<<<<<<<
* result[0] /= z
- * cdef SparseVector vector = SparseVector()
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector)
*/
__pyx_v_z = InsideOutside<prob_t, EdgeProb, SparseVector<prob_t>, EdgeFeaturesAndProbWeightFunction>((__pyx_v_self->hg[0]), __pyx_v_result);
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":135
- * cdef FastSparseVector[LogVal[double]]* result = new FastSparseVector[LogVal[double]]()
- * cdef LogVal[double] z = hypergraph.InsideOutside(self.hg[0], result)
+ * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]()
+ * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result)
* result[0] /= z # <<<<<<<<<<<<<<
- * cdef SparseVector vector = SparseVector()
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector)
* vector.vector = new FastSparseVector[double]()
*/
(__pyx_v_result[0]) /= __pyx_v_z;
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":136
- * cdef LogVal[double] z = hypergraph.InsideOutside(self.hg[0], result)
+ * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result)
* result[0] /= z
- * cdef SparseVector vector = SparseVector() # <<<<<<<<<<<<<<
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<<
* vector.vector = new FastSparseVector[double]()
- * cdef FastSparseVector[LogVal[double]].const_iterator* it = new FastSparseVector[LogVal[double]].const_iterator(result[0], False)
+ * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False)
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":137
* result[0] /= z
- * cdef SparseVector vector = SparseVector()
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector)
* vector.vector = new FastSparseVector[double]() # <<<<<<<<<<<<<<
- * cdef FastSparseVector[LogVal[double]].const_iterator* it = new FastSparseVector[LogVal[double]].const_iterator(result[0], False)
+ * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False)
* cdef unsigned i
*/
__pyx_v_vector->vector = new FastSparseVector<double>();
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":138
- * cdef SparseVector vector = SparseVector()
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector)
* vector.vector = new FastSparseVector[double]()
- * cdef FastSparseVector[LogVal[double]].const_iterator* it = new FastSparseVector[LogVal[double]].const_iterator(result[0], False) # <<<<<<<<<<<<<<
+ * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False) # <<<<<<<<<<<<<<
* cdef unsigned i
* for i in range(result.size()):
*/
- __pyx_v_it = new FastSparseVector<LogVal<double> >::const_iterator((__pyx_v_result[0]), 0);
+ __pyx_v_it = new FastSparseVector<prob_t>::const_iterator((__pyx_v_result[0]), 0);
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":140
- * cdef FastSparseVector[LogVal[double]].const_iterator* it = new FastSparseVector[LogVal[double]].const_iterator(result[0], False)
+ * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False)
* cdef unsigned i
* for i in range(result.size()): # <<<<<<<<<<<<<<
* vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second))
@@ -9817,7 +10616,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_
}
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":152
- * cdef public BaseTRule trule
+ * cdef public TRule trule
*
* cdef init(self, hypergraph.Hypergraph* hg, unsigned i): # <<<<<<<<<<<<<<
* self.hg = hg
@@ -9838,7 +10637,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy
* cdef init(self, hypergraph.Hypergraph* hg, unsigned i):
* self.hg = hg # <<<<<<<<<<<<<<
* self.edge = &hg.edges_[i]
- * self.trule = BaseTRule()
+ * self.trule = TRule.__new__(TRule)
*/
__pyx_v_self->hg = __pyx_v_hg;
@@ -9846,7 +10645,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy
* cdef init(self, hypergraph.Hypergraph* hg, unsigned i):
* self.hg = hg
* self.edge = &hg.edges_[i] # <<<<<<<<<<<<<<
- * self.trule = BaseTRule()
+ * self.trule = TRule.__new__(TRule)
* self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_)
*/
__pyx_v_self->edge = (&(__pyx_v_hg->edges_[__pyx_v_i]));
@@ -9854,21 +10653,22 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":155
* self.hg = hg
* self.edge = &hg.edges_[i]
- * self.trule = BaseTRule() # <<<<<<<<<<<<<<
+ * self.trule = TRule.__new__(TRule) # <<<<<<<<<<<<<<
* self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_)
* return self
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_BaseTRule)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_TRule)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GIVEREF(__pyx_t_1);
__Pyx_GOTREF(__pyx_v_self->trule);
__Pyx_DECREF(((PyObject *)__pyx_v_self->trule));
- __pyx_v_self->trule = ((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_t_1);
+ __pyx_v_self->trule = ((struct __pyx_obj_5_cdec_TRule *)__pyx_t_1);
__pyx_t_1 = 0;
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":156
* self.edge = &hg.edges_[i]
- * self.trule = BaseTRule()
+ * self.trule = TRule.__new__(TRule)
* self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_) # <<<<<<<<<<<<<<
* return self
*
@@ -9876,7 +10676,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy
__pyx_v_self->trule->rule = new boost::shared_ptr<TRule>(__pyx_v_self->edge->rule_);
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":157
- * self.trule = BaseTRule()
+ * self.trule = TRule.__new__(TRule)
* self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_)
* return self # <<<<<<<<<<<<<<
*
@@ -10120,6 +10920,7 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator10(__py
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
@@ -10207,7 +11008,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_14feature_values_1__get__(PyOb
*
* property feature_values:
* def __get__(self): # <<<<<<<<<<<<<<
- * cdef SparseVector vector = SparseVector()
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector)
* vector.vector = new FastSparseVector[double](self.edge.feature_values_)
*/
@@ -10224,18 +11025,19 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_14feature_values___get__(struc
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":178
* property feature_values:
* def __get__(self):
- * cdef SparseVector vector = SparseVector() # <<<<<<<<<<<<<<
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<<
* vector.vector = new FastSparseVector[double](self.edge.feature_values_)
* return vector
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":179
* def __get__(self):
- * cdef SparseVector vector = SparseVector()
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector)
* vector.vector = new FastSparseVector[double](self.edge.feature_values_) # <<<<<<<<<<<<<<
* return vector
*
@@ -10243,7 +11045,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_14feature_values___get__(struc
__pyx_v_vector->vector = new FastSparseVector<double>(__pyx_v_self->edge->feature_values_);
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":180
- * cdef SparseVector vector = SparseVector()
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector)
* vector.vector = new FastSparseVector[double](self.edge.feature_values_)
* return vector # <<<<<<<<<<<<<<
*
@@ -10457,7 +11259,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_5trule_1__get__(PyObject *__py
/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":150
* cdef hypergraph.Hypergraph* hg
* cdef hypergraph.HypergraphEdge* edge
- * cdef public BaseTRule trule # <<<<<<<<<<<<<<
+ * cdef public TRule trule # <<<<<<<<<<<<<<
*
* cdef init(self, hypergraph.Hypergraph* hg, unsigned i):
*/
@@ -10496,12 +11298,12 @@ static int __pyx_pf_5_cdec_14HypergraphEdge_5trule_2__set__(struct __pyx_obj_5_c
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__set__", 0);
- if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5_cdec_BaseTRule))))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5_cdec_TRule))))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_INCREF(__pyx_v_value);
__Pyx_GIVEREF(__pyx_v_value);
__Pyx_GOTREF(__pyx_v_self->trule);
__Pyx_DECREF(((PyObject *)__pyx_v_self->trule));
- __pyx_v_self->trule = ((struct __pyx_obj_5_cdec_BaseTRule *)__pyx_v_value);
+ __pyx_v_self->trule = ((struct __pyx_obj_5_cdec_TRule *)__pyx_v_value);
__pyx_r = 0;
goto __pyx_L0;
@@ -10532,7 +11334,7 @@ static int __pyx_pf_5_cdec_14HypergraphEdge_5trule_4__del__(struct __pyx_obj_5_c
__Pyx_GIVEREF(Py_None);
__Pyx_GOTREF(__pyx_v_self->trule);
__Pyx_DECREF(((PyObject *)__pyx_v_self->trule));
- __pyx_v_self->trule = ((struct __pyx_obj_5_cdec_BaseTRule *)Py_None);
+ __pyx_v_self->trule = ((struct __pyx_obj_5_cdec_TRule *)Py_None);
__pyx_r = 0;
__Pyx_RefNannyFinishContext();
@@ -10711,6 +11513,7 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator11(__pyx_G
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
@@ -10837,6 +11640,7 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator12(__pyx_
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
@@ -11092,11 +11896,11 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5
static int __pyx_pw_5_cdec_7Lattice_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5_cdec_7Lattice_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_inp = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__inp,0};
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
{
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__inp,0};
PyObject* values[1] = {0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
@@ -11109,8 +11913,7 @@ static int __pyx_pw_5_cdec_7Lattice_1__cinit__(PyObject *__pyx_v_self, PyObject
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__inp);
- if (likely(values[0])) kw_args--;
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__inp)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
@@ -11206,10 +12009,18 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_
for (;;) {
if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_4)) {
if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_4)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++;
+ #else
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_4)) {
if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++;
+ #else
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else {
__pyx_t_6 = __pyx_t_5(__pyx_t_4);
if (unlikely(!__pyx_t_6)) {
@@ -11332,7 +12143,7 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_
* self.lattice = new lattice.Lattice()
* lattice.ConvertTextToLattice(string(<char *>inp), self.lattice) # <<<<<<<<<<<<<<
*
- * def __getitem__(self, int index):
+ * def __dealloc__(self):
*/
__pyx_t_8 = PyBytes_AsString(__pyx_v_inp); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
LatticeTools::ConvertTextToLattice(std::string(((char *)__pyx_t_8)), __pyx_v_self->lattice);
@@ -11356,14 +12167,47 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_7Lattice_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index); /*proto*/
-static PyObject *__pyx_pw_5_cdec_7Lattice_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index) {
+static void __pyx_pw_5_cdec_7Lattice_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_5_cdec_7Lattice_3__dealloc__(PyObject *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+ __pyx_pf_5_cdec_7Lattice_2__dealloc__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":19
+ * lattice.ConvertTextToLattice(string(<char *>inp), self.lattice)
+ *
+ * def __dealloc__(self): # <<<<<<<<<<<<<<
+ * del self.lattice
+ *
+ */
+
+static void __pyx_pf_5_cdec_7Lattice_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":20
+ *
+ * def __dealloc__(self):
+ * del self.lattice # <<<<<<<<<<<<<<
+ *
+ * def __getitem__(self, int index):
+ */
+ delete __pyx_v_self->lattice;
+
+ __Pyx_RefNannyFinishContext();
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_7Lattice_5__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index); /*proto*/
+static PyObject *__pyx_pw_5_cdec_7Lattice_5__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index) {
int __pyx_v_index;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
assert(__pyx_arg_index); {
- __pyx_v_index = __Pyx_PyInt_AsInt(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_index = __Pyx_PyInt_AsInt(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
@@ -11371,20 +12215,20 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_3__getitem__(PyObject *__pyx_v_self, P
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5_cdec_7Lattice_2__getitem__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), ((int)__pyx_v_index));
+ __pyx_r = __pyx_pf_5_cdec_7Lattice_4__getitem__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), ((int)__pyx_v_index));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":19
- * lattice.ConvertTextToLattice(string(<char *>inp), self.lattice)
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":22
+ * del self.lattice
*
* def __getitem__(self, int index): # <<<<<<<<<<<<<<
* if not 0 <= index < len(self):
* raise IndexError('lattice index out of range')
*/
-static PyObject *__pyx_pf_5_cdec_7Lattice_2__getitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index) {
+static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index) {
PyObject *__pyx_v_arcs = NULL;
std::vector<LatticeArc> __pyx_v_arc_vector;
LatticeArc *__pyx_v_arc;
@@ -11406,7 +12250,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_2__getitem__(struct __pyx_obj_5_cdec_L
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__getitem__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":20
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":23
*
* def __getitem__(self, int index):
* if not 0 <= index < len(self): # <<<<<<<<<<<<<<
@@ -11415,41 +12259,41 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_2__getitem__(struct __pyx_obj_5_cdec_L
*/
__pyx_t_1 = (0 <= __pyx_v_index);
if (__pyx_t_1) {
- __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_1 = (__pyx_v_index < __pyx_t_2);
}
__pyx_t_3 = (!__pyx_t_1);
if (__pyx_t_3) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":21
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":24
* def __getitem__(self, int index):
* if not 0 <= index < len(self):
* raise IndexError('lattice index out of range') # <<<<<<<<<<<<<<
* arcs = []
* cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index]
*/
- __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_24), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_24), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_Raise(__pyx_t_4, 0, 0, 0);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- {__pyx_filename = __pyx_f[4]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":22
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":25
* if not 0 <= index < len(self):
* raise IndexError('lattice index out of range')
* arcs = [] # <<<<<<<<<<<<<<
* cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index]
* cdef lattice.LatticeArc* arc
*/
- __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_v_arcs = __pyx_t_4;
__pyx_t_4 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":23
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":26
* raise IndexError('lattice index out of range')
* arcs = []
* cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index] # <<<<<<<<<<<<<<
@@ -11458,7 +12302,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_2__getitem__(struct __pyx_obj_5_cdec_L
*/
__pyx_v_arc_vector = ((__pyx_v_self->lattice[0])[__pyx_v_index]);
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":26
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":29
* cdef lattice.LatticeArc* arc
* cdef unsigned i
* for i in range(arc_vector.size()): # <<<<<<<<<<<<<<
@@ -11469,7 +12313,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_2__getitem__(struct __pyx_obj_5_cdec_L
for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
__pyx_v_i = __pyx_t_6;
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":27
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":30
* cdef unsigned i
* for i in range(arc_vector.size()):
* arc = &arc_vector[i] # <<<<<<<<<<<<<<
@@ -11478,16 +12322,16 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_2__getitem__(struct __pyx_obj_5_cdec_L
*/
__pyx_v_arc = (&(__pyx_v_arc_vector[__pyx_v_i]));
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":28
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":31
* for i in range(arc_vector.size()):
* arc = &arc_vector[i]
* label = unicode(TDConvert(arc.label), 'utf8') # <<<<<<<<<<<<<<
* arcs.append((label, arc.cost, arc.dist2next))
* return tuple(arcs)
*/
- __pyx_t_4 = PyBytes_FromString(TD::Convert(__pyx_v_arc->label)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyBytes_FromString(TD::Convert(__pyx_v_arc->label)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
- __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_4));
__Pyx_GIVEREF(((PyObject *)__pyx_t_4));
@@ -11495,25 +12339,25 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_2__getitem__(struct __pyx_obj_5_cdec_L
PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_n_s__utf8));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
__pyx_t_4 = 0;
- __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
__Pyx_XDECREF(((PyObject *)__pyx_v_label));
__pyx_v_label = ((PyObject*)__pyx_t_4);
__pyx_t_4 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":29
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":32
* arc = &arc_vector[i]
* label = unicode(TDConvert(arc.label), 'utf8')
* arcs.append((label, arc.cost, arc.dist2next)) # <<<<<<<<<<<<<<
* return tuple(arcs)
*
*/
- __pyx_t_4 = PyFloat_FromDouble(__pyx_v_arc->cost); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyFloat_FromDouble(__pyx_v_arc->cost); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_7 = PyInt_FromLong(__pyx_v_arc->dist2next); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = PyInt_FromLong(__pyx_v_arc->dist2next); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
- __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_INCREF(((PyObject *)__pyx_v_label));
PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_label));
@@ -11524,11 +12368,11 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_2__getitem__(struct __pyx_obj_5_cdec_L
__Pyx_GIVEREF(__pyx_t_7);
__pyx_t_4 = 0;
__pyx_t_7 = 0;
- __pyx_t_9 = PyList_Append(__pyx_v_arcs, ((PyObject *)__pyx_t_8)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_9 = PyList_Append(__pyx_v_arcs, ((PyObject *)__pyx_t_8)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
}
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":30
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":33
* label = unicode(TDConvert(arc.label), 'utf8')
* arcs.append((label, arc.cost, arc.dist2next))
* return tuple(arcs) # <<<<<<<<<<<<<<
@@ -11536,7 +12380,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_2__getitem__(struct __pyx_obj_5_cdec_L
* def __setitem__(self, int index, tuple arcs):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_8 = ((PyObject *)PyList_AsTuple(__pyx_v_arcs)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = ((PyObject *)PyList_AsTuple(__pyx_v_arcs)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_8));
__pyx_r = ((PyObject *)__pyx_t_8);
__pyx_t_8 = 0;
@@ -11559,14 +12403,14 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_2__getitem__(struct __pyx_obj_5_cdec_L
}
/* Python wrapper */
-static int __pyx_pw_5_cdec_7Lattice_5__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index, PyObject *__pyx_v_arcs); /*proto*/
-static int __pyx_pw_5_cdec_7Lattice_5__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index, PyObject *__pyx_v_arcs) {
+static int __pyx_pw_5_cdec_7Lattice_7__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index, PyObject *__pyx_v_arcs); /*proto*/
+static int __pyx_pw_5_cdec_7Lattice_7__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index, PyObject *__pyx_v_arcs) {
int __pyx_v_index;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
assert(__pyx_arg_index); {
- __pyx_v_index = __Pyx_PyInt_AsInt(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_index = __Pyx_PyInt_AsInt(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
@@ -11574,8 +12418,8 @@ static int __pyx_pw_5_cdec_7Lattice_5__setitem__(PyObject *__pyx_v_self, PyObjec
__Pyx_RefNannyFinishContext();
return -1;
__pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arcs), (&PyTuple_Type), 1, "arcs", 1))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_7Lattice_4__setitem__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), ((int)__pyx_v_index), ((PyObject*)__pyx_v_arcs));
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arcs), (&PyTuple_Type), 1, "arcs", 1))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_7Lattice_6__setitem__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), ((int)__pyx_v_index), ((PyObject*)__pyx_v_arcs));
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = -1;
@@ -11584,7 +12428,7 @@ static int __pyx_pw_5_cdec_7Lattice_5__setitem__(PyObject *__pyx_v_self, PyObjec
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":32
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":35
* return tuple(arcs)
*
* def __setitem__(self, int index, tuple arcs): # <<<<<<<<<<<<<<
@@ -11592,7 +12436,7 @@ static int __pyx_pw_5_cdec_7Lattice_5__setitem__(PyObject *__pyx_v_self, PyObjec
* raise IndexError('lattice index out of range')
*/
-static int __pyx_pf_5_cdec_7Lattice_4__setitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index, PyObject *__pyx_v_arcs) {
+static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index, PyObject *__pyx_v_arcs) {
LatticeArc *__pyx_v_arc;
PyObject *__pyx_v_label = NULL;
PyObject *__pyx_v_cost = NULL;
@@ -11617,7 +12461,7 @@ static int __pyx_pf_5_cdec_7Lattice_4__setitem__(struct __pyx_obj_5_cdec_Lattice
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setitem__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":33
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":36
*
* def __setitem__(self, int index, tuple arcs):
* if not 0 <= index < len(self): # <<<<<<<<<<<<<<
@@ -11626,29 +12470,29 @@ static int __pyx_pf_5_cdec_7Lattice_4__setitem__(struct __pyx_obj_5_cdec_Lattice
*/
__pyx_t_1 = (0 <= __pyx_v_index);
if (__pyx_t_1) {
- __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_1 = (__pyx_v_index < __pyx_t_2);
}
__pyx_t_3 = (!__pyx_t_1);
if (__pyx_t_3) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":34
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":37
* def __setitem__(self, int index, tuple arcs):
* if not 0 <= index < len(self):
* raise IndexError('lattice index out of range') # <<<<<<<<<<<<<<
* cdef lattice.LatticeArc* arc
* for (label, cost, dist2next) in arcs:
*/
- __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_Raise(__pyx_t_4, 0, 0, 0);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- {__pyx_filename = __pyx_f[4]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[4]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L3;
}
__pyx_L3:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":36
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":39
* raise IndexError('lattice index out of range')
* cdef lattice.LatticeArc* arc
* for (label, cost, dist2next) in arcs: # <<<<<<<<<<<<<<
@@ -11656,29 +12500,35 @@ static int __pyx_pf_5_cdec_7Lattice_4__setitem__(struct __pyx_obj_5_cdec_Lattice
* label = label.encode('utf8')
*/
if (unlikely(((PyObject *)__pyx_v_arcs) == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+ {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_4 = ((PyObject *)__pyx_v_arcs); __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = 0;
for (;;) {
if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++;
+ #else
+ __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
PyObject* sequence = __pyx_t_5;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 3)) {
+ if (size > 3) __Pyx_RaiseTooManyValuesError(3);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
- if (unlikely(PyTuple_GET_SIZE(sequence) != 3)) {
- if (PyTuple_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
- else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
__pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_7 = PyTuple_GET_ITEM(sequence, 1);
__pyx_t_8 = PyTuple_GET_ITEM(sequence, 2);
} else {
- if (unlikely(PyList_GET_SIZE(sequence) != 3)) {
- if (PyList_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
- else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
__pyx_t_6 = PyList_GET_ITEM(sequence, 0);
__pyx_t_7 = PyList_GET_ITEM(sequence, 1);
__pyx_t_8 = PyList_GET_ITEM(sequence, 2);
@@ -11686,10 +12536,16 @@ static int __pyx_pf_5_cdec_7Lattice_4__setitem__(struct __pyx_obj_5_cdec_Lattice
__Pyx_INCREF(__pyx_t_6);
__Pyx_INCREF(__pyx_t_7);
__Pyx_INCREF(__pyx_t_8);
+ #else
+ __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
+ } else
+ {
Py_ssize_t index = -1;
- __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
@@ -11699,14 +12555,15 @@ static int __pyx_pf_5_cdec_7Lattice_4__setitem__(struct __pyx_obj_5_cdec_Lattice
__Pyx_GOTREF(__pyx_t_7);
index = 2; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L6_unpacking_failed;
__Pyx_GOTREF(__pyx_t_8);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 3) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 3) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_10 = NULL;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
goto __pyx_L7_unpacking_done;
__pyx_L6_unpacking_failed:;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
- if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
- {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_10 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_L7_unpacking_done:;
}
__Pyx_XDECREF(__pyx_v_label);
@@ -11719,7 +12576,7 @@ static int __pyx_pf_5_cdec_7Lattice_4__setitem__(struct __pyx_obj_5_cdec_Lattice
__pyx_v_dist2next = __pyx_t_8;
__pyx_t_8 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":37
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":40
* cdef lattice.LatticeArc* arc
* for (label, cost, dist2next) in arcs:
* if isinstance(label, unicode): # <<<<<<<<<<<<<<
@@ -11732,16 +12589,16 @@ static int __pyx_pf_5_cdec_7Lattice_4__setitem__(struct __pyx_obj_5_cdec_Lattice
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
if (__pyx_t_3) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":38
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":41
* for (label, cost, dist2next) in arcs:
* if isinstance(label, unicode):
* label = label.encode('utf8') # <<<<<<<<<<<<<<
* arc = new lattice.LatticeArc(TDConvert(<char *>label), cost, dist2next)
* self.lattice[0][index].push_back(arc[0])
*/
- __pyx_t_5 = PyObject_GetAttr(__pyx_v_label, __pyx_n_s__encode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyObject_GetAttr(__pyx_v_label, __pyx_n_s__encode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
- __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_26), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_26), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF(__pyx_v_label);
@@ -11751,19 +12608,19 @@ static int __pyx_pf_5_cdec_7Lattice_4__setitem__(struct __pyx_obj_5_cdec_Lattice
}
__pyx_L8:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":39
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":42
* if isinstance(label, unicode):
* label = label.encode('utf8')
* arc = new lattice.LatticeArc(TDConvert(<char *>label), cost, dist2next) # <<<<<<<<<<<<<<
* self.lattice[0][index].push_back(arc[0])
* del arc
*/
- __pyx_t_11 = PyBytes_AsString(__pyx_v_label); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_cost); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_v_dist2next); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_11 = PyBytes_AsString(__pyx_v_label); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_cost); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_v_dist2next); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_arc = new LatticeArc(TD::Convert(((char *)__pyx_t_11)), __pyx_t_12, __pyx_t_13);
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":40
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":43
* label = label.encode('utf8')
* arc = new lattice.LatticeArc(TDConvert(<char *>label), cost, dist2next)
* self.lattice[0][index].push_back(arc[0]) # <<<<<<<<<<<<<<
@@ -11772,7 +12629,7 @@ static int __pyx_pf_5_cdec_7Lattice_4__setitem__(struct __pyx_obj_5_cdec_Lattice
*/
((__pyx_v_self->lattice[0])[__pyx_v_index]).push_back((__pyx_v_arc[0]));
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":41
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":44
* arc = new lattice.LatticeArc(TDConvert(<char *>label), cost, dist2next)
* self.lattice[0][index].push_back(arc[0])
* del arc # <<<<<<<<<<<<<<
@@ -11803,17 +12660,17 @@ static int __pyx_pf_5_cdec_7Lattice_4__setitem__(struct __pyx_obj_5_cdec_Lattice
}
/* Python wrapper */
-static Py_ssize_t __pyx_pw_5_cdec_7Lattice_7__len__(PyObject *__pyx_v_self); /*proto*/
-static Py_ssize_t __pyx_pw_5_cdec_7Lattice_7__len__(PyObject *__pyx_v_self) {
+static Py_ssize_t __pyx_pw_5_cdec_7Lattice_9__len__(PyObject *__pyx_v_self); /*proto*/
+static Py_ssize_t __pyx_pw_5_cdec_7Lattice_9__len__(PyObject *__pyx_v_self) {
Py_ssize_t __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_7Lattice_6__len__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_7Lattice_8__len__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":43
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":46
* del arc
*
* def __len__(self): # <<<<<<<<<<<<<<
@@ -11821,12 +12678,12 @@ static Py_ssize_t __pyx_pw_5_cdec_7Lattice_7__len__(PyObject *__pyx_v_self) {
*
*/
-static Py_ssize_t __pyx_pf_5_cdec_7Lattice_6__len__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
+static Py_ssize_t __pyx_pf_5_cdec_7Lattice_8__len__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
Py_ssize_t __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__len__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":44
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":47
*
* def __len__(self):
* return self.lattice.size() # <<<<<<<<<<<<<<
@@ -11843,17 +12700,17 @@ static Py_ssize_t __pyx_pf_5_cdec_7Lattice_6__len__(struct __pyx_obj_5_cdec_Latt
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_7Lattice_9__str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_7Lattice_9__str__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pw_5_cdec_7Lattice_11__str__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_7Lattice_11__str__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_7Lattice_8__str__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_7Lattice_10__str__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":46
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":49
* return self.lattice.size()
*
* def __str__(self): # <<<<<<<<<<<<<<
@@ -11861,7 +12718,7 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_9__str__(PyObject *__pyx_v_self) {
*
*/
-static PyObject *__pyx_pf_5_cdec_7Lattice_8__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_7Lattice_10__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
@@ -11870,7 +12727,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_8__str__(struct __pyx_obj_5_cdec_Latti
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__str__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":47
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":50
*
* def __str__(self):
* return hypergraph.AsPLF(self.lattice[0], True).c_str() # <<<<<<<<<<<<<<
@@ -11878,7 +12735,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_8__str__(struct __pyx_obj_5_cdec_Latti
* def __iter__(self):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->lattice[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->lattice[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
__pyx_r = ((PyObject *)__pyx_t_1);
__pyx_t_1 = 0;
@@ -11895,20 +12752,20 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_8__str__(struct __pyx_obj_5_cdec_Latti
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_7Lattice_12generator13(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+static PyObject *__pyx_gb_5_cdec_7Lattice_14generator13(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_7Lattice_11__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_7Lattice_11__iter__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pw_5_cdec_7Lattice_13__iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_7Lattice_13__iter__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_7Lattice_10__iter__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_7Lattice_12__iter__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":49
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":52
* return hypergraph.AsPLF(self.lattice[0], True).c_str()
*
* def __iter__(self): # <<<<<<<<<<<<<<
@@ -11916,7 +12773,7 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_11__iter__(PyObject *__pyx_v_self) {
* for i in range(len(self)):
*/
-static PyObject *__pyx_pf_5_cdec_7Lattice_10__iter__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_7Lattice_12__iter__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@@ -11934,7 +12791,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_10__iter__(struct __pyx_obj_5_cdec_Lat
__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_7Lattice_12generator13, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Lattice_14generator13, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -11952,7 +12809,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_10__iter__(struct __pyx_obj_5_cdec_Lat
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_7Lattice_12generator13(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+static PyObject *__pyx_gb_5_cdec_7Lattice_14generator13(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *)__pyx_generator->closure);
PyObject *__pyx_r = NULL;
@@ -11969,27 +12826,27 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_12generator13(__pyx_GeneratorObject *_
return NULL;
}
__pyx_L3_first_run:;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":51
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":54
* def __iter__(self):
* cdef unsigned i
* for i in range(len(self)): # <<<<<<<<<<<<<<
* yield self[i]
*
*/
- __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
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/lattice.pxi":52
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":55
* cdef unsigned i
* for i in range(len(self)):
* yield self[i] # <<<<<<<<<<<<<<
*
- * def __dealloc__(self):
+ * def todot(self):
*/
- __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
@@ -12003,7 +12860,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_12generator13(__pyx_GeneratorObject *_
__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[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
@@ -12013,44 +12870,12 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_12generator13(__pyx_GeneratorObject *_
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
/* Python wrapper */
-static void __pyx_pw_5_cdec_7Lattice_14__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pw_5_cdec_7Lattice_14__dealloc__(PyObject *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
- __pyx_pf_5_cdec_7Lattice_13__dealloc__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
- __Pyx_RefNannyFinishContext();
-}
-
-/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":54
- * yield self[i]
- *
- * def __dealloc__(self): # <<<<<<<<<<<<<<
- * del self.lattice
- *
- */
-
-static void __pyx_pf_5_cdec_7Lattice_13__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__dealloc__", 0);
-
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":55
- *
- * def __dealloc__(self):
- * del self.lattice # <<<<<<<<<<<<<<
- *
- * def todot(self):
- */
- delete __pyx_v_self->lattice;
-
- __Pyx_RefNannyFinishContext();
-}
-
-/* Python wrapper */
static PyObject *__pyx_pw_5_cdec_7Lattice_16todot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_5_cdec_7Lattice_16todot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
@@ -12069,7 +12894,6 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_5todot_1lines(PyObject *__pyx_self, CY
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lines (wrapper)", 0);
- __pyx_self = __pyx_self;
__pyx_r = __pyx_pf_5_cdec_7Lattice_5todot_lines(__pyx_self);
__Pyx_RefNannyFinishContext();
return __pyx_r;
@@ -12237,10 +13061,18 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj
for (;;) {
if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_3)) {
if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
+ #else
+ __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) {
if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
+ #else
+ __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else {
__pyx_t_1 = __pyx_t_4(__pyx_t_3);
if (unlikely(!__pyx_t_1)) {
@@ -12279,10 +13111,18 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj
for (;;) {
if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_5)) {
if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++;
+ #else
+ __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_5)) {
if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++;
+ #else
+ __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else {
__pyx_t_1 = __pyx_t_7(__pyx_t_5);
if (unlikely(!__pyx_t_1)) {
@@ -12296,21 +13136,22 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj
}
if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
PyObject* sequence = __pyx_t_1;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 3)) {
+ if (size > 3) __Pyx_RaiseTooManyValuesError(3);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
- if (unlikely(PyTuple_GET_SIZE(sequence) != 3)) {
- if (PyTuple_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
- else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
__pyx_t_8 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_9 = PyTuple_GET_ITEM(sequence, 1);
__pyx_t_10 = PyTuple_GET_ITEM(sequence, 2);
} else {
- if (unlikely(PyList_GET_SIZE(sequence) != 3)) {
- if (PyList_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
- else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
__pyx_t_8 = PyList_GET_ITEM(sequence, 0);
__pyx_t_9 = PyList_GET_ITEM(sequence, 1);
__pyx_t_10 = PyList_GET_ITEM(sequence, 2);
@@ -12318,8 +13159,14 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj
__Pyx_INCREF(__pyx_t_8);
__Pyx_INCREF(__pyx_t_9);
__Pyx_INCREF(__pyx_t_10);
+ #else
+ __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
+ } else
+ {
Py_ssize_t index = -1;
__pyx_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_11);
@@ -12332,12 +13179,13 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj
index = 2; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L11_unpacking_failed;
__Pyx_GOTREF(__pyx_t_10);
if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_12 = NULL;
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
goto __pyx_L12_unpacking_done;
__pyx_L11_unpacking_failed:;
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
- if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
+ __pyx_t_12 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
{__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_L12_unpacking_done:;
}
@@ -12472,12 +13320,13 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":57
- * del self.lattice
+ * yield self[i]
*
* def todot(self): # <<<<<<<<<<<<<<
* def lines():
@@ -12777,7 +13626,7 @@ static PyObject *__pyx_pw_5_cdec_9Candidate_4fmap_1__get__(PyObject *__pyx_v_sel
*
* property fmap:
* def __get__(self): # <<<<<<<<<<<<<<
- * cdef SparseVector fmap = SparseVector()
+ * cdef SparseVector fmap = SparseVector.__new__(SparseVector)
* fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap)
*/
@@ -12794,18 +13643,19 @@ static PyObject *__pyx_pf_5_cdec_9Candidate_4fmap___get__(struct __pyx_obj_5_cde
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":22
* property fmap:
* def __get__(self):
- * cdef SparseVector fmap = SparseVector() # <<<<<<<<<<<<<<
+ * cdef SparseVector fmap = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<<
* fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap)
* return fmap
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_fmap = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":23
* def __get__(self):
- * cdef SparseVector fmap = SparseVector()
+ * cdef SparseVector fmap = SparseVector.__new__(SparseVector)
* fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap) # <<<<<<<<<<<<<<
* return fmap
*
@@ -12813,7 +13663,7 @@ static PyObject *__pyx_pf_5_cdec_9Candidate_4fmap___get__(struct __pyx_obj_5_cde
__pyx_v_fmap->vector = new FastSparseVector<weight_t>(__pyx_v_self->candidate->fmap);
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":24
- * cdef SparseVector fmap = SparseVector()
+ * cdef SparseVector fmap = SparseVector.__new__(SparseVector)
* fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap)
* return fmap # <<<<<<<<<<<<<<
*
@@ -12850,7 +13700,7 @@ static PyObject *__pyx_pw_5_cdec_9Candidate_5score_1__get__(PyObject *__pyx_v_se
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":14
* cdef class Candidate:
- * cdef mteval.Candidate* candidate
+ * cdef mteval.const_Candidate* candidate
* cdef public float score # <<<<<<<<<<<<<<
*
* property words:
@@ -13202,10 +14052,18 @@ static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator14(__pyx_GeneratorO
for (;;) {
if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_3)) {
if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) {
if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else {
__pyx_t_2 = __pyx_t_4(__pyx_t_3);
if (unlikely(!__pyx_t_2)) {
@@ -13261,6 +14119,7 @@ static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator14(__pyx_GeneratorO
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
@@ -13536,11 +14395,11 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x
static int __pyx_pw_5_cdec_12CandidateSet_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5_cdec_12CandidateSet_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
struct __pyx_obj_5_cdec_SegmentEvaluator *__pyx_v_evaluator = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__evaluator,0};
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
{
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__evaluator,0};
PyObject* values[1] = {0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
@@ -13553,8 +14412,7 @@ static int __pyx_pw_5_cdec_12CandidateSet_1__cinit__(PyObject *__pyx_v_self, PyO
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__evaluator);
- if (likely(values[0])) kw_args--;
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__evaluator)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
@@ -13955,6 +14813,7 @@ static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator15(__pyx_GeneratorObj
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
@@ -13964,11 +14823,11 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_12add_kbest(PyObject *__pyx_v_se
static PyObject *__pyx_pw_5_cdec_12CandidateSet_12add_kbest(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_hypergraph = 0;
unsigned int __pyx_v_k;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__hypergraph,&__pyx_n_s__k,0};
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("add_kbest (wrapper)", 0);
{
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__hypergraph,&__pyx_n_s__k,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
@@ -13982,12 +14841,10 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_12add_kbest(PyObject *__pyx_v_se
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__hypergraph);
- if (likely(values[0])) kw_args--;
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__hypergraph)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
- values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__k);
- if (likely(values[1])) kw_args--;
+ if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__k)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("add_kbest", 1, 2, 2, 1); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
@@ -14260,11 +15117,11 @@ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_4candidate_set(struct __pyx_
static int __pyx_pw_5_cdec_6Scorer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_5_cdec_6Scorer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_name = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__name,0};
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
{
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__name,0};
PyObject* values[1] = {0};
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":121
@@ -14410,11 +15267,11 @@ static void __pyx_pf_5_cdec_6Scorer_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_
static PyObject *__pyx_pw_5_cdec_6Scorer_5__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5_cdec_6Scorer_5__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_refs = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__refs,0};
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
{
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__refs,0};
PyObject* values[1] = {0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
@@ -14427,8 +15284,7 @@ static PyObject *__pyx_pw_5_cdec_6Scorer_5__call__(PyObject *__pyx_v_self, PyObj
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__refs);
- if (likely(values[0])) kw_args--;
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__refs)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
@@ -14551,10 +15407,18 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
for (;;) {
if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_1)) {
if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_7 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++;
+ #else
+ __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_1)) {
if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++;
+ #else
+ __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else {
__pyx_t_7 = __pyx_t_6(__pyx_t_1);
if (unlikely(!__pyx_t_7)) {
@@ -14954,9 +15818,10 @@ static void __pyx_f_5_cdec__compute_sufficient_stats(void *__pyx_v_metric_, std:
* out.fields[i] = ss[i]
*/
if (unlikely(((PyObject *)__pyx_v_ss) == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
+ {__pyx_filename = __pyx_f[5]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
- __pyx_t_7 = PyList_GET_SIZE(((PyObject *)__pyx_v_ss));
+ __pyx_t_7 = PyList_GET_SIZE(((PyObject *)__pyx_v_ss)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_out->fields.resize(__pyx_t_7);
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":170
@@ -14967,9 +15832,10 @@ static void __pyx_f_5_cdec__compute_sufficient_stats(void *__pyx_v_metric_, std:
*
*/
if (unlikely(((PyObject *)__pyx_v_ss) == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
+ {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
- __pyx_t_7 = PyList_GET_SIZE(((PyObject *)__pyx_v_ss));
+ __pyx_t_7 = PyList_GET_SIZE(((PyObject *)__pyx_v_ss)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_7; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
@@ -14980,6 +15846,10 @@ static void __pyx_f_5_cdec__compute_sufficient_stats(void *__pyx_v_metric_, std:
*
* cdef class Metric:
*/
+ if (unlikely(((PyObject *)__pyx_v_ss) == Py_None)) {
+ PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+ {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
__pyx_t_5 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_ss), __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_5); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -15087,11 +15957,11 @@ static int __pyx_pf_5_cdec_6Metric___cinit__(struct __pyx_obj_5_cdec_Metric *__p
static PyObject *__pyx_pw_5_cdec_6Metric_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_5_cdec_6Metric_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_refs = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__refs,0};
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
{
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__refs,0};
PyObject* values[1] = {0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
@@ -15104,8 +15974,7 @@ static PyObject *__pyx_pw_5_cdec_6Metric_3__call__(PyObject *__pyx_v_self, PyObj
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__refs);
- if (likely(values[0])) kw_args--;
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__refs)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
@@ -15230,11 +16099,11 @@ static PyObject *__pyx_pw_5_cdec_6Metric_7evaluate(PyObject *__pyx_v_self, PyObj
static PyObject *__pyx_pw_5_cdec_6Metric_7evaluate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
CYTHON_UNUSED PyObject *__pyx_v_hyp = 0;
CYTHON_UNUSED PyObject *__pyx_v_refs = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__hyp,&__pyx_n_s__refs,0};
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("evaluate (wrapper)", 0);
{
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__hyp,&__pyx_n_s__refs,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
@@ -15248,12 +16117,10 @@ static PyObject *__pyx_pw_5_cdec_6Metric_7evaluate(PyObject *__pyx_v_self, PyObj
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__hyp);
- if (likely(values[0])) kw_args--;
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__hyp)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
- values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__refs);
- if (likely(values[1])) kw_args--;
+ if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__refs)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("evaluate", 1, 2, 2, 1); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
@@ -15334,7 +16201,6 @@ static PyObject *__pyx_pw_5_cdec_3_make_config(PyObject *__pyx_self, PyObject *_
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("_make_config (wrapper)", 0);
- __pyx_self = __pyx_self;
__pyx_r = __pyx_pf_5_cdec_2_make_config(__pyx_self, ((PyObject *)__pyx_v_config));
__Pyx_RefNannyFinishContext();
return __pyx_r;
@@ -15438,10 +16304,18 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener
for (;;) {
if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else {
__pyx_t_2 = __pyx_t_4(__pyx_t_1);
if (unlikely(!__pyx_t_2)) {
@@ -15455,27 +16329,33 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener
}
if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
PyObject* sequence = __pyx_t_2;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 2)) {
+ if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
- if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
- if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
- else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
__pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
} else {
- if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
- if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
- else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
__pyx_t_5 = PyList_GET_ITEM(sequence, 0);
__pyx_t_6 = PyList_GET_ITEM(sequence, 1);
}
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(__pyx_t_6);
+ #else
+ __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
+ } else
+ {
Py_ssize_t index = -1;
__pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
@@ -15486,12 +16366,13 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener
index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
__Pyx_GOTREF(__pyx_t_6);
if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = NULL;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
goto __pyx_L7_unpacking_done;
__pyx_L6_unpacking_failed:;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
- if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
+ __pyx_t_8 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_L7_unpacking_done:;
}
@@ -15543,10 +16424,18 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener
for (;;) {
if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_2)) {
if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++;
+ #else
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_2)) {
if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++;
+ #else
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else {
__pyx_t_6 = __pyx_t_11(__pyx_t_2);
if (unlikely(!__pyx_t_6)) {
@@ -15560,27 +16449,33 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener
}
if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
PyObject* sequence = __pyx_t_6;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 2)) {
+ if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
- if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
- if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
- else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
__pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_7 = PyTuple_GET_ITEM(sequence, 1);
} else {
- if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
- if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
- else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
__pyx_t_5 = PyList_GET_ITEM(sequence, 0);
__pyx_t_7 = PyList_GET_ITEM(sequence, 1);
}
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(__pyx_t_7);
+ #else
+ __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else {
+ } else
+ {
Py_ssize_t index = -1;
__pyx_t_12 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_12);
@@ -15591,12 +16486,13 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener
index = 1; __pyx_t_7 = __pyx_t_8(__pyx_t_12); if (unlikely(!__pyx_t_7)) goto __pyx_L11_unpacking_failed;
__Pyx_GOTREF(__pyx_t_7);
if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_12), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = NULL;
__Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
goto __pyx_L12_unpacking_done;
__pyx_L11_unpacking_failed:;
__Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
- if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
+ __pyx_t_8 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_L12_unpacking_done:;
}
@@ -15700,10 +16596,18 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener
for (;;) {
if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_2)) {
if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++;
+ #else
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_2)) {
if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++;
+ #else
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else {
__pyx_t_6 = __pyx_t_11(__pyx_t_2);
if (unlikely(!__pyx_t_6)) {
@@ -15827,6 +16731,7 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
@@ -15836,13 +16741,13 @@ static int __pyx_pw_5_cdec_7Decoder_1__cinit__(PyObject *__pyx_v_self, PyObject
static int __pyx_pw_5_cdec_7Decoder_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_config_str = 0;
PyObject *__pyx_v_config = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__config_str,0};
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
__pyx_v_config = PyDict_New(); if (unlikely(!__pyx_v_config)) return -1;
__Pyx_GOTREF(__pyx_v_config);
{
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__config_str,0};
PyObject* values[1] = {0};
/* "_cdec.pyx":43
@@ -15985,10 +16890,18 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator20(__pyx_Generato
for (;;) {
if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_2)) {
if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
+ #else
+ __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_2)) {
if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
+ #else
+ __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else {
__pyx_t_3 = __pyx_t_5(__pyx_t_2);
if (unlikely(!__pyx_t_3)) {
@@ -16037,6 +16950,7 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator20(__pyx_Generato
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
@@ -16221,7 +17135,7 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_
* cdef istringstream* config_stream = new istringstream(config_str)
* self.dec = new decoder.Decoder(config_stream) # <<<<<<<<<<<<<<
* del config_stream
- * self.weights = DenseVector()
+ * self.weights = DenseVector.__new__(DenseVector)
*/
__pyx_v_self->dec = new Decoder(__pyx_v_config_stream);
@@ -16229,7 +17143,7 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_
* cdef istringstream* config_stream = new istringstream(config_str)
* self.dec = new decoder.Decoder(config_stream)
* del config_stream # <<<<<<<<<<<<<<
- * self.weights = DenseVector()
+ * self.weights = DenseVector.__new__(DenseVector)
* self.weights.vector = &self.dec.CurrentWeightVector()
*/
delete __pyx_v_config_stream;
@@ -16237,12 +17151,13 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_
/* "_cdec.pyx":58
* self.dec = new decoder.Decoder(config_stream)
* del config_stream
- * self.weights = DenseVector() # <<<<<<<<<<<<<<
+ * self.weights = DenseVector.__new__(DenseVector) # <<<<<<<<<<<<<<
* self.weights.vector = &self.dec.CurrentWeightVector()
- *
+ * self.weights.owned = True
*/
- __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_DenseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_DenseVector)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5_cdec_DenseVector)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GIVEREF(__pyx_t_6);
__Pyx_GOTREF(__pyx_v_self->weights);
__Pyx_DECREF(((PyObject *)__pyx_v_self->weights));
@@ -16251,13 +17166,22 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_
/* "_cdec.pyx":59
* del config_stream
- * self.weights = DenseVector()
+ * self.weights = DenseVector.__new__(DenseVector)
* self.weights.vector = &self.dec.CurrentWeightVector() # <<<<<<<<<<<<<<
+ * self.weights.owned = True
*
- * def __dealloc__(self):
*/
__pyx_v_self->weights->vector = (&__pyx_v_self->dec->CurrentWeightVector());
+ /* "_cdec.pyx":60
+ * self.weights = DenseVector.__new__(DenseVector)
+ * self.weights.vector = &self.dec.CurrentWeightVector()
+ * self.weights.owned = True # <<<<<<<<<<<<<<
+ *
+ * def __dealloc__(self):
+ */
+ __pyx_v_self->weights->owned = 1;
+
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
@@ -16283,8 +17207,8 @@ static void __pyx_pw_5_cdec_7Decoder_3__dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannyFinishContext();
}
-/* "_cdec.pyx":61
- * self.weights.vector = &self.dec.CurrentWeightVector()
+/* "_cdec.pyx":62
+ * self.weights.owned = True
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
* del self.dec
@@ -16295,7 +17219,7 @@ static void __pyx_pf_5_cdec_7Decoder_2__dealloc__(CYTHON_UNUSED struct __pyx_obj
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__", 0);
- /* "_cdec.pyx":62
+ /* "_cdec.pyx":63
*
* def __dealloc__(self):
* del self.dec # <<<<<<<<<<<<<<
@@ -16318,7 +17242,7 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_7weights_1__get__(PyObject *__pyx_v_se
return __pyx_r;
}
-/* "_cdec.pyx":65
+/* "_cdec.pyx":66
*
* property weights:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -16331,7 +17255,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_7weights___get__(struct __pyx_obj_5_cd
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__", 0);
- /* "_cdec.pyx":66
+ /* "_cdec.pyx":67
* property weights:
* def __get__(self):
* return self.weights # <<<<<<<<<<<<<<
@@ -16361,7 +17285,7 @@ static int __pyx_pw_5_cdec_7Decoder_7weights_3__set__(PyObject *__pyx_v_self, Py
return __pyx_r;
}
-/* "_cdec.pyx":68
+/* "_cdec.pyx":69
* return self.weights
*
* def __set__(self, weights): # <<<<<<<<<<<<<<
@@ -16388,7 +17312,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__set__", 0);
- /* "_cdec.pyx":69
+ /* "_cdec.pyx":70
*
* def __set__(self, weights):
* if isinstance(weights, DenseVector): # <<<<<<<<<<<<<<
@@ -16401,7 +17325,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_2) {
- /* "_cdec.pyx":70
+ /* "_cdec.pyx":71
* def __set__(self, weights):
* if isinstance(weights, DenseVector):
* self.weights.vector[0] = (<DenseVector> weights).vector[0] # <<<<<<<<<<<<<<
@@ -16412,7 +17336,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De
goto __pyx_L3;
}
- /* "_cdec.pyx":71
+ /* "_cdec.pyx":72
* if isinstance(weights, DenseVector):
* self.weights.vector[0] = (<DenseVector> weights).vector[0]
* elif isinstance(weights, SparseVector): # <<<<<<<<<<<<<<
@@ -16425,7 +17349,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_2) {
- /* "_cdec.pyx":72
+ /* "_cdec.pyx":73
* self.weights.vector[0] = (<DenseVector> weights).vector[0]
* elif isinstance(weights, SparseVector):
* self.weights.vector.clear() # <<<<<<<<<<<<<<
@@ -16434,23 +17358,23 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De
*/
__pyx_v_self->weights->vector->clear();
- /* "_cdec.pyx":73
+ /* "_cdec.pyx":74
* elif isinstance(weights, SparseVector):
* self.weights.vector.clear()
* ((<SparseVector> weights).vector[0]).init_vector(self.weights.vector) # <<<<<<<<<<<<<<
* elif isinstance(weights, dict):
- * for fname, fval in weights.items():
+ * self.weights.vector.clear()
*/
(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_weights)->vector[0]).init_vector(__pyx_v_self->weights->vector);
goto __pyx_L3;
}
- /* "_cdec.pyx":74
+ /* "_cdec.pyx":75
* self.weights.vector.clear()
* ((<SparseVector> weights).vector[0]).init_vector(self.weights.vector)
* elif isinstance(weights, dict): # <<<<<<<<<<<<<<
+ * self.weights.vector.clear()
* for fname, fval in weights.items():
- * self.weights[fname] = fval
*/
__pyx_t_1 = ((PyObject *)((PyObject*)(&PyDict_Type)));
__Pyx_INCREF(__pyx_t_1);
@@ -16458,23 +17382,32 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_2) {
- /* "_cdec.pyx":75
+ /* "_cdec.pyx":76
* ((<SparseVector> weights).vector[0]).init_vector(self.weights.vector)
* elif isinstance(weights, dict):
+ * self.weights.vector.clear() # <<<<<<<<<<<<<<
+ * for fname, fval in weights.items():
+ * self.weights[fname] = fval
+ */
+ __pyx_v_self->weights->vector->clear();
+
+ /* "_cdec.pyx":77
+ * elif isinstance(weights, dict):
+ * self.weights.vector.clear()
* for fname, fval in weights.items(): # <<<<<<<<<<<<<<
* self.weights[fname] = fval
* else:
*/
- __pyx_t_1 = PyObject_GetAttr(__pyx_v_weights, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_weights, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
__pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
__pyx_t_5 = NULL;
} else {
- __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext;
}
@@ -16482,16 +17415,24 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De
for (;;) {
if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_1)) {
if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
+ #else
+ __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) {
if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
+ #else
+ __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
} else {
__pyx_t_3 = __pyx_t_5(__pyx_t_1);
if (unlikely(!__pyx_t_3)) {
if (PyErr_Occurred()) {
if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
- else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
break;
}
@@ -16499,29 +17440,35 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De
}
if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
PyObject* sequence = __pyx_t_3;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 2)) {
+ if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
- if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
- if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
- else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
__pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_7 = PyTuple_GET_ITEM(sequence, 1);
} else {
- if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
- if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
- else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
__pyx_t_6 = PyList_GET_ITEM(sequence, 0);
__pyx_t_7 = PyList_GET_ITEM(sequence, 1);
}
__Pyx_INCREF(__pyx_t_6);
__Pyx_INCREF(__pyx_t_7);
+ #else
+ __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
+ } else
+ {
Py_ssize_t index = -1;
- __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
@@ -16529,14 +17476,15 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De
__Pyx_GOTREF(__pyx_t_6);
index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
__Pyx_GOTREF(__pyx_t_7);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_9 = NULL;
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
goto __pyx_L7_unpacking_done;
__pyx_L6_unpacking_failed:;
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
- if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_9 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_L7_unpacking_done:;
}
__Pyx_XDECREF(__pyx_v_fname);
@@ -16546,40 +17494,40 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De
__pyx_v_fval = __pyx_t_7;
__pyx_t_7 = 0;
- /* "_cdec.pyx":76
- * elif isinstance(weights, dict):
+ /* "_cdec.pyx":78
+ * self.weights.vector.clear()
* for fname, fval in weights.items():
* self.weights[fname] = fval # <<<<<<<<<<<<<<
* else:
* raise TypeError('cannot initialize weights with %s' % type(weights))
*/
- if (PyObject_SetItem(((PyObject *)__pyx_v_self->weights), __pyx_v_fname, __pyx_v_fval) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyObject_SetItem(((PyObject *)__pyx_v_self->weights), __pyx_v_fname, __pyx_v_fval) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
goto __pyx_L3;
}
/*else*/ {
- /* "_cdec.pyx":78
+ /* "_cdec.pyx":80
* self.weights[fname] = fval
* else:
* raise TypeError('cannot initialize weights with %s' % type(weights)) # <<<<<<<<<<<<<<
*
* property formalism:
*/
- __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_49), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_49), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
__Pyx_GIVEREF(((PyObject *)__pyx_t_1));
__pyx_t_1 = 0;
- __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_L3:;
@@ -16611,12 +17559,12 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_9formalism_1__get__(PyObject *__pyx_v_
return __pyx_r;
}
-/* "_cdec.pyx":81
+/* "_cdec.pyx":83
*
* property formalism:
* def __get__(self): # <<<<<<<<<<<<<<
* cdef variables_map* conf = &self.dec.GetConf()
- * return conf[0]['formalism'].as_str().c_str()
+ * return conf[0]['formalism'].as_str()
*/
static PyObject *__pyx_pf_5_cdec_7Decoder_9formalism___get__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self) {
@@ -16629,24 +17577,24 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_9formalism___get__(struct __pyx_obj_5_
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
- /* "_cdec.pyx":82
+ /* "_cdec.pyx":84
* property formalism:
* def __get__(self):
* cdef variables_map* conf = &self.dec.GetConf() # <<<<<<<<<<<<<<
- * return conf[0]['formalism'].as_str().c_str()
+ * return conf[0]['formalism'].as_str()
*
*/
__pyx_v_conf = (&__pyx_v_self->dec->GetConf());
- /* "_cdec.pyx":83
+ /* "_cdec.pyx":85
* def __get__(self):
* cdef variables_map* conf = &self.dec.GetConf()
- * return conf[0]['formalism'].as_str().c_str() # <<<<<<<<<<<<<<
+ * return conf[0]['formalism'].as_str() # <<<<<<<<<<<<<<
*
* def read_weights(self, weights):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyBytes_FromString(((__pyx_v_conf[0])[__pyx_k__formalism]).as<std::string>().c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __pyx_convert_string_to_py_(((__pyx_v_conf[0])[__pyx_k__formalism]).as<std::string>()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
__pyx_r = ((PyObject *)__pyx_t_1);
__pyx_t_1 = 0;
@@ -16675,8 +17623,8 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_5read_weights(PyObject *__pyx_v_self,
return __pyx_r;
}
-/* "_cdec.pyx":85
- * return conf[0]['formalism'].as_str().c_str()
+/* "_cdec.pyx":87
+ * return conf[0]['formalism'].as_str()
*
* def read_weights(self, weights): # <<<<<<<<<<<<<<
* with open(weights) as fp:
@@ -16711,7 +17659,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("read_weights", 0);
- /* "_cdec.pyx":86
+ /* "_cdec.pyx":88
*
* def read_weights(self, weights):
* with open(weights) as fp: # <<<<<<<<<<<<<<
@@ -16719,19 +17667,19 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
* if line.strip().startswith('#'): continue
*/
/*with:*/ {
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__pyx_v_weights);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_weights);
__Pyx_GIVEREF(__pyx_v_weights);
- __pyx_t_2 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
- __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____exit__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____exit__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____enter__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____enter__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
@@ -16746,7 +17694,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__pyx_v_fp = __pyx_t_4;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- /* "_cdec.pyx":87
+ /* "_cdec.pyx":89
* def read_weights(self, weights):
* with open(weights) as fp:
* for line in fp: # <<<<<<<<<<<<<<
@@ -16757,23 +17705,31 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__pyx_t_4 = __pyx_v_fp; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0;
__pyx_t_9 = NULL;
} else {
- __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_fp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_fp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext;
}
for (;;) {
if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_4)) {
if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;};
+ #endif
} else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_4)) {
if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
__pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;};
+ #endif
} else {
__pyx_t_2 = __pyx_t_9(__pyx_t_4);
if (unlikely(!__pyx_t_2)) {
if (PyErr_Occurred()) {
if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
- else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
}
break;
}
@@ -16783,25 +17739,25 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__pyx_v_line = __pyx_t_2;
__pyx_t_2 = 0;
- /* "_cdec.pyx":88
+ /* "_cdec.pyx":90
* with open(weights) as fp:
* for line in fp:
* if line.strip().startswith('#'): continue # <<<<<<<<<<<<<<
* fname, value = line.split()
* self.weights[fname.strip()] = float(value)
*/
- __pyx_t_2 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__strip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_2 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__strip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__startswith); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__startswith); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_51), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_51), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_10) {
goto __pyx_L16_continue;
@@ -16809,43 +17765,49 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
}
__pyx_L18:;
- /* "_cdec.pyx":89
+ /* "_cdec.pyx":91
* for line in fp:
* if line.strip().startswith('#'): continue
* fname, value = line.split() # <<<<<<<<<<<<<<
* self.weights[fname.strip()] = float(value)
*
*/
- __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
PyObject* sequence = __pyx_t_2;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 2)) {
+ if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
- if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
- if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
- else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- }
__pyx_t_1 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_11 = PyTuple_GET_ITEM(sequence, 1);
} else {
- if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
- if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
- else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- }
__pyx_t_1 = PyList_GET_ITEM(sequence, 0);
__pyx_t_11 = PyList_GET_ITEM(sequence, 1);
}
__Pyx_INCREF(__pyx_t_1);
__Pyx_INCREF(__pyx_t_11);
+ #else
+ __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ #endif
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
+ } else
+ {
Py_ssize_t index = -1;
- __pyx_t_12 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_12 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__Pyx_GOTREF(__pyx_t_12);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
@@ -16853,14 +17815,15 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__Pyx_GOTREF(__pyx_t_1);
index = 1; __pyx_t_11 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L19_unpacking_failed;
__Pyx_GOTREF(__pyx_t_11);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_13 = NULL;
__Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
goto __pyx_L20_unpacking_done;
__pyx_L19_unpacking_failed:;
__Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
- if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
- if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_13 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__pyx_L20_unpacking_done:;
}
__Pyx_XDECREF(__pyx_v_fname);
@@ -16870,22 +17833,22 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__pyx_v_value = __pyx_t_11;
__pyx_t_11 = 0;
- /* "_cdec.pyx":90
+ /* "_cdec.pyx":92
* if line.strip().startswith('#'): continue
* fname, value = line.split()
* self.weights[fname.strip()] = float(value) # <<<<<<<<<<<<<<
*
* def translate(self, sentence, grammar=None):
*/
- __pyx_t_14 = __Pyx_PyObject_AsDouble(__pyx_v_value); if (unlikely(__pyx_t_14 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- __pyx_t_2 = PyFloat_FromDouble(__pyx_t_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_14 = __Pyx_PyObject_AsDouble(__pyx_v_value); if (unlikely(__pyx_t_14 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_2 = PyFloat_FromDouble(__pyx_t_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_11 = PyObject_GetAttr(__pyx_v_fname, __pyx_n_s__strip); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_11 = PyObject_GetAttr(__pyx_v_fname, __pyx_n_s__strip); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__Pyx_GOTREF(__pyx_t_11);
- __pyx_t_1 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- if (PyObject_SetItem(((PyObject *)__pyx_v_self->weights), __pyx_t_1, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ if (PyObject_SetItem(((PyObject *)__pyx_v_self->weights), __pyx_t_1, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_L16_continue:;
@@ -16903,7 +17866,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- /* "_cdec.pyx":86
+ /* "_cdec.pyx":88
*
* def read_weights(self, weights):
* with open(weights) as fp: # <<<<<<<<<<<<<<
@@ -16912,11 +17875,11 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
*/
/*except:*/ {
__Pyx_AddTraceback("_cdec.Decoder.read_weights", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+ if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+ __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
__Pyx_GOTREF(__pyx_t_11);
__Pyx_INCREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4);
@@ -16929,11 +17892,11 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_15 = PyObject_Call(__pyx_t_3, __pyx_t_11, NULL);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+ if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
__Pyx_GOTREF(__pyx_t_15);
__pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_15);
__Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
- if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+ if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
__pyx_t_16 = (!__pyx_t_10);
if (__pyx_t_16) {
__Pyx_GIVEREF(__pyx_t_4);
@@ -16941,7 +17904,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__Pyx_GIVEREF(__pyx_t_1);
__Pyx_ErrRestore(__pyx_t_4, __pyx_t_2, __pyx_t_1);
__pyx_t_4 = 0; __pyx_t_2 = 0; __pyx_t_1 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
goto __pyx_L23;
}
__pyx_L23:;
@@ -16969,11 +17932,11 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
if (__pyx_t_3) {
__pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_52, NULL);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_7);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
goto __pyx_L24;
@@ -17008,14 +17971,14 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyO
static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_sentence = 0;
PyObject *__pyx_v_grammar = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__sentence,&__pyx_n_s__grammar,0};
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("translate (wrapper)", 0);
{
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__sentence,&__pyx_n_s__grammar,0};
PyObject* values[2] = {0,0};
- /* "_cdec.pyx":92
+ /* "_cdec.pyx":94
* self.weights[fname.strip()] = float(value)
*
* def translate(self, sentence, grammar=None): # <<<<<<<<<<<<<<
@@ -17035,8 +17998,7 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyO
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sentence);
- if (likely(values[0])) kw_args--;
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sentence)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (kw_args > 0) {
@@ -17045,7 +18007,7 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyO
}
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "translate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "translate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -17060,7 +18022,7 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyO
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("translate", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("translate", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("_cdec.Decoder.translate", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
@@ -17088,7 +18050,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("translate", 0);
- /* "_cdec.pyx":94
+ /* "_cdec.pyx":96
* def translate(self, sentence, grammar=None):
* cdef bytes input_str
* if isinstance(sentence, unicode) or isinstance(sentence, str): # <<<<<<<<<<<<<<
@@ -17110,19 +18072,19 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
}
if (__pyx_t_4) {
- /* "_cdec.pyx":95
+ /* "_cdec.pyx":97
* cdef bytes input_str
* if isinstance(sentence, unicode) or isinstance(sentence, str):
* input_str = as_str(sentence.strip()) # <<<<<<<<<<<<<<
* elif isinstance(sentence, Lattice):
* input_str = str(sentence) # PLF format
*/
- __pyx_t_1 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyBytes_FromString(__pyx_f_5_cdec_as_str(__pyx_t_5, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_FromString(__pyx_f_5_cdec_as_str(__pyx_t_5, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_v_input_str = __pyx_t_1;
@@ -17130,7 +18092,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
goto __pyx_L3;
}
- /* "_cdec.pyx":96
+ /* "_cdec.pyx":98
* if isinstance(sentence, unicode) or isinstance(sentence, str):
* input_str = as_str(sentence.strip())
* elif isinstance(sentence, Lattice): # <<<<<<<<<<<<<<
@@ -17143,62 +18105,62 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_4) {
- /* "_cdec.pyx":97
+ /* "_cdec.pyx":99
* input_str = as_str(sentence.strip())
* elif isinstance(sentence, Lattice):
* input_str = str(sentence) # PLF format # <<<<<<<<<<<<<<
* else:
* raise TypeError('Cannot translate input type %s' % type(sentence))
*/
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__pyx_v_sentence);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sentence);
__Pyx_GIVEREF(__pyx_v_sentence);
- __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
- if (!(likely(PyBytes_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(PyBytes_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_input_str = ((PyObject*)__pyx_t_5);
__pyx_t_5 = 0;
goto __pyx_L3;
}
/*else*/ {
- /* "_cdec.pyx":99
+ /* "_cdec.pyx":101
* input_str = str(sentence) # PLF format
* else:
* raise TypeError('Cannot translate input type %s' % type(sentence)) # <<<<<<<<<<<<<<
* if grammar:
* if isinstance(grammar, str) or isinstance(grammar, unicode):
*/
- __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_53), ((PyObject *)Py_TYPE(__pyx_v_sentence))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_53), ((PyObject *)Py_TYPE(__pyx_v_sentence))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_5));
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_5));
__Pyx_GIVEREF(((PyObject *)__pyx_t_5));
__pyx_t_5 = 0;
- __pyx_t_5 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__Pyx_Raise(__pyx_t_5, 0, 0, 0);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_L3:;
- /* "_cdec.pyx":100
+ /* "_cdec.pyx":102
* else:
* raise TypeError('Cannot translate input type %s' % type(sentence))
* if grammar: # <<<<<<<<<<<<<<
* if isinstance(grammar, str) or isinstance(grammar, unicode):
* self.dec.AddSupplementalGrammarFromString(string(as_str(grammar)))
*/
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_grammar); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_grammar); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__pyx_t_4) {
- /* "_cdec.pyx":101
+ /* "_cdec.pyx":103
* raise TypeError('Cannot translate input type %s' % type(sentence))
* if grammar:
* if isinstance(grammar, str) or isinstance(grammar, unicode): # <<<<<<<<<<<<<<
@@ -17220,7 +18182,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
}
if (__pyx_t_3) {
- /* "_cdec.pyx":102
+ /* "_cdec.pyx":104
* if grammar:
* if isinstance(grammar, str) or isinstance(grammar, unicode):
* self.dec.AddSupplementalGrammarFromString(string(as_str(grammar))) # <<<<<<<<<<<<<<
@@ -17232,19 +18194,19 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
}
/*else*/ {
- /* "_cdec.pyx":104
+ /* "_cdec.pyx":106
* self.dec.AddSupplementalGrammarFromString(string(as_str(grammar)))
* else:
* self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0]) # <<<<<<<<<<<<<<
* cdef decoder.BasicObserver observer = decoder.BasicObserver()
* self.dec.Decode(string(input_str), &observer)
*/
- __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_INCREF(__pyx_v_grammar);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_grammar);
__Pyx_GIVEREF(__pyx_v_grammar);
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TextGrammar)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TextGrammar)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
__pyx_v_self->dec->AddSupplementalGrammar((((struct __pyx_obj_5_cdec_TextGrammar *)__pyx_t_1)->__pyx_base.grammar[0]));
@@ -17255,7 +18217,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
}
__pyx_L4:;
- /* "_cdec.pyx":105
+ /* "_cdec.pyx":107
* else:
* self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0])
* cdef decoder.BasicObserver observer = decoder.BasicObserver() # <<<<<<<<<<<<<<
@@ -17264,17 +18226,17 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
*/
__pyx_v_observer = BasicObserver();
- /* "_cdec.pyx":106
+ /* "_cdec.pyx":108
* self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0])
* cdef decoder.BasicObserver observer = decoder.BasicObserver()
* self.dec.Decode(string(input_str), &observer) # <<<<<<<<<<<<<<
* if observer.hypergraph == NULL:
* raise ParseFailed()
*/
- __pyx_t_6 = PyBytes_AsString(((PyObject *)__pyx_v_input_str)); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyBytes_AsString(((PyObject *)__pyx_v_input_str)); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_self->dec->Decode(std::string(__pyx_t_6), (&__pyx_v_observer));
- /* "_cdec.pyx":107
+ /* "_cdec.pyx":109
* cdef decoder.BasicObserver observer = decoder.BasicObserver()
* self.dec.Decode(string(input_str), &observer)
* if observer.hypergraph == NULL: # <<<<<<<<<<<<<<
@@ -17284,38 +18246,38 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
__pyx_t_3 = (__pyx_v_observer.hypergraph == NULL);
if (__pyx_t_3) {
- /* "_cdec.pyx":108
+ /* "_cdec.pyx":110
* self.dec.Decode(string(input_str), &observer)
* if observer.hypergraph == NULL:
* raise ParseFailed() # <<<<<<<<<<<<<<
* cdef Hypergraph hg = Hypergraph()
* hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0])
*/
- __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ParseFailed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ParseFailed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_Raise(__pyx_t_5, 0, 0, 0);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L6;
}
__pyx_L6:;
- /* "_cdec.pyx":109
+ /* "_cdec.pyx":111
* if observer.hypergraph == NULL:
* raise ParseFailed()
* cdef Hypergraph hg = Hypergraph() # <<<<<<<<<<<<<<
* hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0])
* return hg
*/
- __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Hypergraph)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Hypergraph)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__pyx_v_hg = ((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_t_5);
__pyx_t_5 = 0;
- /* "_cdec.pyx":110
+ /* "_cdec.pyx":112
* raise ParseFailed()
* cdef Hypergraph hg = Hypergraph()
* hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0]) # <<<<<<<<<<<<<<
@@ -17323,7 +18285,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
*/
__pyx_v_hg->hg = new Hypergraph((__pyx_v_observer.hypergraph[0]));
- /* "_cdec.pyx":111
+ /* "_cdec.pyx":113
* cdef Hypergraph hg = Hypergraph()
* hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0])
* return hg # <<<<<<<<<<<<<<
@@ -17348,13 +18310,65 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
return __pyx_r;
}
-static PyObject *__pyx_tp_new_5_cdec_DenseVector(PyTypeObject *t, PyObject *a, PyObject *k) {
+/* "string.to_py":25
+ *
+ * @cname("__pyx_convert_string_to_py_")
+ * cdef object __pyx_convert_string_to_py_(string& s): # <<<<<<<<<<<<<<
+ * return s.data()[:s.size()]
+ *
+ */
+
+static PyObject *__pyx_convert_string_to_py_(const std::string &__pyx_v_s) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__pyx_convert_string_to_py_", 0);
+
+ /* "string.to_py":26
+ * @cname("__pyx_convert_string_to_py_")
+ * cdef object __pyx_convert_string_to_py_(string& s):
+ * return s.data()[:s.size()] # <<<<<<<<<<<<<<
+ *
+ *
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __pyx_t_1 = PyBytes_FromStringAndSize(__pyx_v_s.data() + 0, __pyx_v_s.size() - 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_r = ((PyObject *)__pyx_t_1);
+ __pyx_t_1 = 0;
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("string.to_py.__pyx_convert_string_to_py_", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = 0;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static PyObject *__pyx_tp_new_5_cdec_DenseVector(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
return o;
}
static void __pyx_tp_dealloc_5_cdec_DenseVector(PyObject *o) {
+ {
+ PyObject *etype, *eval, *etb;
+ PyErr_Fetch(&etype, &eval, &etb);
+ ++Py_REFCNT(o);
+ __pyx_pw_5_cdec_11DenseVector_3__dealloc__(o);
+ if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+ --Py_REFCNT(o);
+ PyErr_Restore(etype, eval, etb);
+ }
(*Py_TYPE(o)->tp_free)(o);
}
static PyObject *__pyx_sq_item_5_cdec_DenseVector(PyObject *o, Py_ssize_t i) {
@@ -17367,7 +18381,7 @@ static PyObject *__pyx_sq_item_5_cdec_DenseVector(PyObject *o, Py_ssize_t i) {
static int __pyx_mp_ass_subscript_5_cdec_DenseVector(PyObject *o, PyObject *i, PyObject *v) {
if (v) {
- return __pyx_pw_5_cdec_11DenseVector_5__setitem__(o, i, v);
+ return __pyx_pw_5_cdec_11DenseVector_9__setitem__(o, i, v);
}
else {
PyErr_Format(PyExc_NotImplementedError,
@@ -17377,8 +18391,8 @@ static int __pyx_mp_ass_subscript_5_cdec_DenseVector(PyObject *o, PyObject *i, P
}
static PyMethodDef __pyx_methods_5_cdec_DenseVector[] = {
- {__Pyx_NAMESTR("dot"), (PyCFunction)__pyx_pw_5_cdec_11DenseVector_10dot, METH_O, __Pyx_DOCSTR(0)},
- {__Pyx_NAMESTR("tosparse"), (PyCFunction)__pyx_pw_5_cdec_11DenseVector_12tosparse, METH_NOARGS, __Pyx_DOCSTR(0)},
+ {__Pyx_NAMESTR("dot"), (PyCFunction)__pyx_pw_5_cdec_11DenseVector_14dot, METH_O, __Pyx_DOCSTR(0)},
+ {__Pyx_NAMESTR("tosparse"), (PyCFunction)__pyx_pw_5_cdec_11DenseVector_16tosparse, METH_NOARGS, __Pyx_DOCSTR(0)},
{0, 0, 0, 0}
};
@@ -17441,7 +18455,7 @@ static PyNumberMethods __pyx_tp_as_number_DenseVector = {
};
static PySequenceMethods __pyx_tp_as_sequence_DenseVector = {
- __pyx_pw_5_cdec_11DenseVector_1__len__, /*sq_length*/
+ __pyx_pw_5_cdec_11DenseVector_5__len__, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
__pyx_sq_item_5_cdec_DenseVector, /*sq_item*/
@@ -17454,8 +18468,8 @@ static PySequenceMethods __pyx_tp_as_sequence_DenseVector = {
};
static PyMappingMethods __pyx_tp_as_mapping_DenseVector = {
- __pyx_pw_5_cdec_11DenseVector_1__len__, /*mp_length*/
- __pyx_pw_5_cdec_11DenseVector_3__getitem__, /*mp_subscript*/
+ __pyx_pw_5_cdec_11DenseVector_5__len__, /*mp_length*/
+ __pyx_pw_5_cdec_11DenseVector_7__getitem__, /*mp_subscript*/
__pyx_mp_ass_subscript_5_cdec_DenseVector, /*mp_ass_subscript*/
};
@@ -17510,7 +18524,7 @@ static PyTypeObject __pyx_type_5_cdec_DenseVector = {
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
- __pyx_pw_5_cdec_11DenseVector_7__iter__, /*tp_iter*/
+ __pyx_pw_5_cdec_11DenseVector_11__iter__, /*tp_iter*/
0, /*tp_iternext*/
__pyx_methods_5_cdec_DenseVector, /*tp_methods*/
0, /*tp_members*/
@@ -17520,7 +18534,7 @@ static PyTypeObject __pyx_type_5_cdec_DenseVector = {
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
- 0, /*tp_init*/
+ __pyx_pw_5_cdec_11DenseVector_1__init__, /*tp_init*/
0, /*tp_alloc*/
__pyx_tp_new_5_cdec_DenseVector, /*tp_new*/
0, /*tp_free*/
@@ -17536,7 +18550,7 @@ static PyTypeObject __pyx_type_5_cdec_DenseVector = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec_SparseVector(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec_SparseVector(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
return o;
@@ -17547,7 +18561,7 @@ static void __pyx_tp_dealloc_5_cdec_SparseVector(PyObject *o) {
PyObject *etype, *eval, *etb;
PyErr_Fetch(&etype, &eval, &etb);
++Py_REFCNT(o);
- __pyx_pw_5_cdec_12SparseVector_1__dealloc__(o);
+ __pyx_pw_5_cdec_12SparseVector_3__dealloc__(o);
if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
--Py_REFCNT(o);
PyErr_Restore(etype, eval, etb);
@@ -17564,7 +18578,7 @@ static PyObject *__pyx_sq_item_5_cdec_SparseVector(PyObject *o, Py_ssize_t i) {
static int __pyx_mp_ass_subscript_5_cdec_SparseVector(PyObject *o, PyObject *i, PyObject *v) {
if (v) {
- return __pyx_pw_5_cdec_12SparseVector_7__setitem__(o, i, v);
+ return __pyx_pw_5_cdec_12SparseVector_9__setitem__(o, i, v);
}
else {
PyErr_Format(PyExc_NotImplementedError,
@@ -17574,22 +18588,22 @@ static int __pyx_mp_ass_subscript_5_cdec_SparseVector(PyObject *o, PyObject *i,
}
static PyMethodDef __pyx_methods_5_cdec_SparseVector[] = {
- {__Pyx_NAMESTR("copy"), (PyCFunction)__pyx_pw_5_cdec_12SparseVector_3copy, METH_NOARGS, __Pyx_DOCSTR(0)},
- {__Pyx_NAMESTR("dot"), (PyCFunction)__pyx_pw_5_cdec_12SparseVector_12dot, METH_O, __Pyx_DOCSTR(0)},
+ {__Pyx_NAMESTR("copy"), (PyCFunction)__pyx_pw_5_cdec_12SparseVector_5copy, METH_NOARGS, __Pyx_DOCSTR(0)},
+ {__Pyx_NAMESTR("dot"), (PyCFunction)__pyx_pw_5_cdec_12SparseVector_14dot, METH_O, __Pyx_DOCSTR(0)},
{0, 0, 0, 0}
};
static PyNumberMethods __pyx_tp_as_number_SparseVector = {
- __pyx_pw_5_cdec_12SparseVector_30__add__, /*nb_add*/
- __pyx_pw_5_cdec_12SparseVector_32__sub__, /*nb_subtract*/
- __pyx_pw_5_cdec_12SparseVector_34__mul__, /*nb_multiply*/
+ __pyx_pw_5_cdec_12SparseVector_32__add__, /*nb_add*/
+ __pyx_pw_5_cdec_12SparseVector_34__sub__, /*nb_subtract*/
+ __pyx_pw_5_cdec_12SparseVector_36__mul__, /*nb_multiply*/
#if PY_MAJOR_VERSION < 3
- __pyx_pw_5_cdec_12SparseVector_36__div__, /*nb_divide*/
+ __pyx_pw_5_cdec_12SparseVector_38__div__, /*nb_divide*/
#endif
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
- __pyx_pw_5_cdec_12SparseVector_20__neg__, /*nb_negative*/
+ __pyx_pw_5_cdec_12SparseVector_22__neg__, /*nb_negative*/
0, /*nb_positive*/
0, /*nb_absolute*/
0, /*nb_nonzero*/
@@ -17615,11 +18629,11 @@ static PyNumberMethods __pyx_tp_as_number_SparseVector = {
#if PY_MAJOR_VERSION < 3
0, /*nb_hex*/
#endif
- __pyx_pw_5_cdec_12SparseVector_22__iadd__, /*nb_inplace_add*/
- __pyx_pw_5_cdec_12SparseVector_24__isub__, /*nb_inplace_subtract*/
- __pyx_pw_5_cdec_12SparseVector_26__imul__, /*nb_inplace_multiply*/
+ __pyx_pw_5_cdec_12SparseVector_24__iadd__, /*nb_inplace_add*/
+ __pyx_pw_5_cdec_12SparseVector_26__isub__, /*nb_inplace_subtract*/
+ __pyx_pw_5_cdec_12SparseVector_28__imul__, /*nb_inplace_multiply*/
#if PY_MAJOR_VERSION < 3
- __pyx_pw_5_cdec_12SparseVector_28__idiv__, /*nb_inplace_divide*/
+ __pyx_pw_5_cdec_12SparseVector_30__idiv__, /*nb_inplace_divide*/
#endif
0, /*nb_inplace_remainder*/
0, /*nb_inplace_power*/
@@ -17638,21 +18652,21 @@ static PyNumberMethods __pyx_tp_as_number_SparseVector = {
};
static PySequenceMethods __pyx_tp_as_sequence_SparseVector = {
- __pyx_pw_5_cdec_12SparseVector_16__len__, /*sq_length*/
+ __pyx_pw_5_cdec_12SparseVector_18__len__, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
__pyx_sq_item_5_cdec_SparseVector, /*sq_item*/
0, /*sq_slice*/
0, /*sq_ass_item*/
0, /*sq_ass_slice*/
- __pyx_pw_5_cdec_12SparseVector_18__contains__, /*sq_contains*/
+ __pyx_pw_5_cdec_12SparseVector_20__contains__, /*sq_contains*/
0, /*sq_inplace_concat*/
0, /*sq_inplace_repeat*/
};
static PyMappingMethods __pyx_tp_as_mapping_SparseVector = {
- __pyx_pw_5_cdec_12SparseVector_16__len__, /*mp_length*/
- __pyx_pw_5_cdec_12SparseVector_5__getitem__, /*mp_subscript*/
+ __pyx_pw_5_cdec_12SparseVector_18__len__, /*mp_length*/
+ __pyx_pw_5_cdec_12SparseVector_7__getitem__, /*mp_subscript*/
__pyx_mp_ass_subscript_5_cdec_SparseVector, /*mp_ass_subscript*/
};
@@ -17705,9 +18719,9 @@ static PyTypeObject __pyx_type_5_cdec_SparseVector = {
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
- __pyx_pw_5_cdec_12SparseVector_14__richcmp__, /*tp_richcompare*/
+ __pyx_pw_5_cdec_12SparseVector_16__richcmp__, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
- __pyx_pw_5_cdec_12SparseVector_9__iter__, /*tp_iter*/
+ __pyx_pw_5_cdec_12SparseVector_11__iter__, /*tp_iter*/
0, /*tp_iternext*/
__pyx_methods_5_cdec_SparseVector, /*tp_methods*/
0, /*tp_members*/
@@ -17717,7 +18731,7 @@ static PyTypeObject __pyx_type_5_cdec_SparseVector = {
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
- 0, /*tp_init*/
+ __pyx_pw_5_cdec_12SparseVector_1__init__, /*tp_init*/
0, /*tp_alloc*/
__pyx_tp_new_5_cdec_SparseVector, /*tp_new*/
0, /*tp_free*/
@@ -17733,7 +18747,7 @@ static PyTypeObject __pyx_type_5_cdec_SparseVector = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec_NT(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec_NT(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
return o;
@@ -17743,11 +18757,11 @@ static void __pyx_tp_dealloc_5_cdec_NT(PyObject *o) {
(*Py_TYPE(o)->tp_free)(o);
}
-static PyObject *__pyx_getprop_5_cdec_2NT_cat(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_2NT_cat(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_2NT_3cat_1__get__(o);
}
-static int __pyx_setprop_5_cdec_2NT_cat(PyObject *o, PyObject *v, void *x) {
+static int __pyx_setprop_5_cdec_2NT_cat(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
if (v) {
return __pyx_pw_5_cdec_2NT_3cat_3__set__(o, v);
}
@@ -17757,11 +18771,11 @@ static int __pyx_setprop_5_cdec_2NT_cat(PyObject *o, PyObject *v, void *x) {
}
}
-static PyObject *__pyx_getprop_5_cdec_2NT_ref(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_2NT_ref(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_2NT_3ref_1__get__(o);
}
-static int __pyx_setprop_5_cdec_2NT_ref(PyObject *o, PyObject *v, void *x) {
+static int __pyx_setprop_5_cdec_2NT_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
if (v) {
return __pyx_pw_5_cdec_2NT_3ref_3__set__(o, v);
}
@@ -17935,7 +18949,7 @@ static PyTypeObject __pyx_type_5_cdec_NT = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec_NTRef(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec_NTRef(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
return o;
@@ -17945,11 +18959,11 @@ static void __pyx_tp_dealloc_5_cdec_NTRef(PyObject *o) {
(*Py_TYPE(o)->tp_free)(o);
}
-static PyObject *__pyx_getprop_5_cdec_5NTRef_ref(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_5NTRef_ref(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_5NTRef_3ref_1__get__(o);
}
-static int __pyx_setprop_5_cdec_5NTRef_ref(PyObject *o, PyObject *v, void *x) {
+static int __pyx_setprop_5_cdec_5NTRef_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
if (v) {
return __pyx_pw_5_cdec_5NTRef_3ref_3__set__(o, v);
}
@@ -18122,18 +19136,18 @@ static PyTypeObject __pyx_type_5_cdec_NTRef = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec_BaseTRule(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec_TRule(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
return o;
}
-static void __pyx_tp_dealloc_5_cdec_BaseTRule(PyObject *o) {
+static void __pyx_tp_dealloc_5_cdec_TRule(PyObject *o) {
{
PyObject *etype, *eval, *etb;
PyErr_Fetch(&etype, &eval, &etb);
++Py_REFCNT(o);
- __pyx_pw_5_cdec_9BaseTRule_1__dealloc__(o);
+ __pyx_pw_5_cdec_5TRule_3__dealloc__(o);
if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
--Py_REFCNT(o);
PyErr_Restore(etype, eval, etb);
@@ -18141,17 +19155,17 @@ static void __pyx_tp_dealloc_5_cdec_BaseTRule(PyObject *o) {
(*Py_TYPE(o)->tp_free)(o);
}
-static PyObject *__pyx_getprop_5_cdec_9BaseTRule_arity(PyObject *o, void *x) {
- return __pyx_pw_5_cdec_9BaseTRule_5arity_1__get__(o);
+static PyObject *__pyx_getprop_5_cdec_5TRule_arity(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_5TRule_5arity_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_9BaseTRule_f(PyObject *o, void *x) {
- return __pyx_pw_5_cdec_9BaseTRule_1f_1__get__(o);
+static PyObject *__pyx_getprop_5_cdec_5TRule_f(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_5TRule_1f_1__get__(o);
}
-static int __pyx_setprop_5_cdec_9BaseTRule_f(PyObject *o, PyObject *v, void *x) {
+static int __pyx_setprop_5_cdec_5TRule_f(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
if (v) {
- return __pyx_pw_5_cdec_9BaseTRule_1f_3__set__(o, v);
+ return __pyx_pw_5_cdec_5TRule_1f_3__set__(o, v);
}
else {
PyErr_SetString(PyExc_NotImplementedError, "__del__");
@@ -18159,13 +19173,13 @@ static int __pyx_setprop_5_cdec_9BaseTRule_f(PyObject *o, PyObject *v, void *x)
}
}
-static PyObject *__pyx_getprop_5_cdec_9BaseTRule_e(PyObject *o, void *x) {
- return __pyx_pw_5_cdec_9BaseTRule_1e_1__get__(o);
+static PyObject *__pyx_getprop_5_cdec_5TRule_e(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_5TRule_1e_1__get__(o);
}
-static int __pyx_setprop_5_cdec_9BaseTRule_e(PyObject *o, PyObject *v, void *x) {
+static int __pyx_setprop_5_cdec_5TRule_e(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
if (v) {
- return __pyx_pw_5_cdec_9BaseTRule_1e_3__set__(o, v);
+ return __pyx_pw_5_cdec_5TRule_1e_3__set__(o, v);
}
else {
PyErr_SetString(PyExc_NotImplementedError, "__del__");
@@ -18173,13 +19187,13 @@ static int __pyx_setprop_5_cdec_9BaseTRule_e(PyObject *o, PyObject *v, void *x)
}
}
-static PyObject *__pyx_getprop_5_cdec_9BaseTRule_a(PyObject *o, void *x) {
- return __pyx_pw_5_cdec_9BaseTRule_1a_1__get__(o);
+static PyObject *__pyx_getprop_5_cdec_5TRule_a(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_5TRule_1a_1__get__(o);
}
-static int __pyx_setprop_5_cdec_9BaseTRule_a(PyObject *o, PyObject *v, void *x) {
+static int __pyx_setprop_5_cdec_5TRule_a(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
if (v) {
- return __pyx_pw_5_cdec_9BaseTRule_1a_4__set__(o, v);
+ return __pyx_pw_5_cdec_5TRule_1a_4__set__(o, v);
}
else {
PyErr_SetString(PyExc_NotImplementedError, "__del__");
@@ -18187,13 +19201,13 @@ static int __pyx_setprop_5_cdec_9BaseTRule_a(PyObject *o, PyObject *v, void *x)
}
}
-static PyObject *__pyx_getprop_5_cdec_9BaseTRule_scores(PyObject *o, void *x) {
- return __pyx_pw_5_cdec_9BaseTRule_6scores_1__get__(o);
+static PyObject *__pyx_getprop_5_cdec_5TRule_scores(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_5TRule_6scores_1__get__(o);
}
-static int __pyx_setprop_5_cdec_9BaseTRule_scores(PyObject *o, PyObject *v, void *x) {
+static int __pyx_setprop_5_cdec_5TRule_scores(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
if (v) {
- return __pyx_pw_5_cdec_9BaseTRule_6scores_3__set__(o, v);
+ return __pyx_pw_5_cdec_5TRule_6scores_3__set__(o, v);
}
else {
PyErr_SetString(PyExc_NotImplementedError, "__del__");
@@ -18201,13 +19215,13 @@ static int __pyx_setprop_5_cdec_9BaseTRule_scores(PyObject *o, PyObject *v, void
}
}
-static PyObject *__pyx_getprop_5_cdec_9BaseTRule_lhs(PyObject *o, void *x) {
- return __pyx_pw_5_cdec_9BaseTRule_3lhs_1__get__(o);
+static PyObject *__pyx_getprop_5_cdec_5TRule_lhs(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_5TRule_3lhs_1__get__(o);
}
-static int __pyx_setprop_5_cdec_9BaseTRule_lhs(PyObject *o, PyObject *v, void *x) {
+static int __pyx_setprop_5_cdec_5TRule_lhs(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
if (v) {
- return __pyx_pw_5_cdec_9BaseTRule_3lhs_3__set__(o, v);
+ return __pyx_pw_5_cdec_5TRule_3lhs_3__set__(o, v);
}
else {
PyErr_SetString(PyExc_NotImplementedError, "__del__");
@@ -18215,187 +19229,20 @@ static int __pyx_setprop_5_cdec_9BaseTRule_lhs(PyObject *o, PyObject *v, void *x
}
}
-static PyMethodDef __pyx_methods_5_cdec_BaseTRule[] = {
+static PyMethodDef __pyx_methods_5_cdec_TRule[] = {
{0, 0, 0, 0}
};
-static struct PyGetSetDef __pyx_getsets_5_cdec_BaseTRule[] = {
- {(char *)"arity", __pyx_getprop_5_cdec_9BaseTRule_arity, 0, 0, 0},
- {(char *)"f", __pyx_getprop_5_cdec_9BaseTRule_f, __pyx_setprop_5_cdec_9BaseTRule_f, 0, 0},
- {(char *)"e", __pyx_getprop_5_cdec_9BaseTRule_e, __pyx_setprop_5_cdec_9BaseTRule_e, 0, 0},
- {(char *)"a", __pyx_getprop_5_cdec_9BaseTRule_a, __pyx_setprop_5_cdec_9BaseTRule_a, 0, 0},
- {(char *)"scores", __pyx_getprop_5_cdec_9BaseTRule_scores, __pyx_setprop_5_cdec_9BaseTRule_scores, 0, 0},
- {(char *)"lhs", __pyx_getprop_5_cdec_9BaseTRule_lhs, __pyx_setprop_5_cdec_9BaseTRule_lhs, 0, 0},
+static struct PyGetSetDef __pyx_getsets_5_cdec_TRule[] = {
+ {(char *)"arity", __pyx_getprop_5_cdec_5TRule_arity, 0, 0, 0},
+ {(char *)"f", __pyx_getprop_5_cdec_5TRule_f, __pyx_setprop_5_cdec_5TRule_f, 0, 0},
+ {(char *)"e", __pyx_getprop_5_cdec_5TRule_e, __pyx_setprop_5_cdec_5TRule_e, 0, 0},
+ {(char *)"a", __pyx_getprop_5_cdec_5TRule_a, __pyx_setprop_5_cdec_5TRule_a, 0, 0},
+ {(char *)"scores", __pyx_getprop_5_cdec_5TRule_scores, __pyx_setprop_5_cdec_5TRule_scores, 0, 0},
+ {(char *)"lhs", __pyx_getprop_5_cdec_5TRule_lhs, __pyx_setprop_5_cdec_5TRule_lhs, 0, 0},
{0, 0, 0, 0, 0}
};
-static PyNumberMethods __pyx_tp_as_number_BaseTRule = {
- 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_BaseTRule = {
- 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_BaseTRule = {
- 0, /*mp_length*/
- 0, /*mp_subscript*/
- 0, /*mp_ass_subscript*/
-};
-
-static PyBufferProcs __pyx_tp_as_buffer_BaseTRule = {
- #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_BaseTRule = {
- PyVarObject_HEAD_INIT(0, 0)
- __Pyx_NAMESTR("_cdec.BaseTRule"), /*tp_name*/
- sizeof(struct __pyx_obj_5_cdec_BaseTRule), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_5_cdec_BaseTRule, /*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_BaseTRule, /*tp_as_number*/
- &__pyx_tp_as_sequence_BaseTRule, /*tp_as_sequence*/
- &__pyx_tp_as_mapping_BaseTRule, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- __pyx_pw_5_cdec_9BaseTRule_3__str__, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- &__pyx_tp_as_buffer_BaseTRule, /*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_BaseTRule, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_5_cdec_BaseTRule, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_5_cdec_BaseTRule, /*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_TRule(PyTypeObject *t, PyObject *a, PyObject *k) {
- PyObject *o = __pyx_tp_new_5_cdec_BaseTRule(t, a, k);
- if (!o) return 0;
- if (__pyx_pw_5_cdec_5TRule_1__cinit__(o, a, k) < 0) {
- Py_DECREF(o); o = 0;
- }
- return o;
-}
-
-static PyMethodDef __pyx_methods_5_cdec_TRule[] = {
- {0, 0, 0, 0}
-};
-
static PyNumberMethods __pyx_tp_as_number_TRule = {
0, /*nb_add*/
0, /*nb_subtract*/
@@ -18499,7 +19346,7 @@ static PyTypeObject __pyx_type_5_cdec_TRule = {
__Pyx_NAMESTR("_cdec.TRule"), /*tp_name*/
sizeof(struct __pyx_obj_5_cdec_TRule), /*tp_basicsize*/
0, /*tp_itemsize*/
- __pyx_tp_dealloc_5_cdec_BaseTRule, /*tp_dealloc*/
+ __pyx_tp_dealloc_5_cdec_TRule, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
@@ -18514,7 +19361,7 @@ static PyTypeObject __pyx_type_5_cdec_TRule = {
&__pyx_tp_as_mapping_TRule, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
- 0, /*tp_str*/
+ __pyx_pw_5_cdec_5TRule_5__str__, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
&__pyx_tp_as_buffer_TRule, /*tp_as_buffer*/
@@ -18528,13 +19375,13 @@ static PyTypeObject __pyx_type_5_cdec_TRule = {
0, /*tp_iternext*/
__pyx_methods_5_cdec_TRule, /*tp_methods*/
0, /*tp_members*/
- 0, /*tp_getset*/
+ __pyx_getsets_5_cdec_TRule, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
- 0, /*tp_init*/
+ __pyx_pw_5_cdec_5TRule_1__init__, /*tp_init*/
0, /*tp_alloc*/
__pyx_tp_new_5_cdec_TRule, /*tp_new*/
0, /*tp_free*/
@@ -18550,7 +19397,7 @@ static PyTypeObject __pyx_type_5_cdec_TRule = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec_Grammar(PyTypeObject *t, PyObject *a, PyObject *k) {
+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;
return o;
@@ -18569,11 +19416,11 @@ static void __pyx_tp_dealloc_5_cdec_Grammar(PyObject *o) {
(*Py_TYPE(o)->tp_free)(o);
}
-static PyObject *__pyx_getprop_5_cdec_7Grammar_name(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_7Grammar_name(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_7Grammar_4name_1__get__(o);
}
-static int __pyx_setprop_5_cdec_7Grammar_name(PyObject *o, PyObject *v, void *x) {
+static int __pyx_setprop_5_cdec_7Grammar_name(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
if (v) {
return __pyx_pw_5_cdec_7Grammar_4name_3__set__(o, v);
}
@@ -18887,7 +19734,11 @@ static PyTypeObject __pyx_type_5_cdec_TextGrammar = {
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
+ #if CYTHON_COMPILING_IN_PYPY
+ __pyx_pw_5_cdec_7Grammar_3__iter__, /*tp_iter*/
+ #else
0, /*tp_iter*/
+ #endif
0, /*tp_iternext*/
__pyx_methods_5_cdec_TextGrammar, /*tp_methods*/
0, /*tp_members*/
@@ -18913,7 +19764,7 @@ static PyTypeObject __pyx_type_5_cdec_TextGrammar = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec_Hypergraph(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec_Hypergraph(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
return o;
@@ -18932,19 +19783,19 @@ static void __pyx_tp_dealloc_5_cdec_Hypergraph(PyObject *o) {
(*Py_TYPE(o)->tp_free)(o);
}
-static PyObject *__pyx_getprop_5_cdec_10Hypergraph_edges(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_10Hypergraph_edges(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_10Hypergraph_5edges_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_10Hypergraph_nodes(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_10Hypergraph_nodes(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_10Hypergraph_5nodes_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_10Hypergraph_goal(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_10Hypergraph_goal(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_10Hypergraph_4goal_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_10Hypergraph_npaths(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_10Hypergraph_npaths(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_10Hypergraph_6npaths_1__get__(o);
}
@@ -19128,13 +19979,13 @@ static PyTypeObject __pyx_type_5_cdec_Hypergraph = {
};
static struct __pyx_vtabstruct_5_cdec_HypergraphEdge __pyx_vtable_5_cdec_HypergraphEdge;
-static PyObject *__pyx_tp_new_5_cdec_HypergraphEdge(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec_HypergraphEdge(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec_HypergraphEdge *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
p = ((struct __pyx_obj_5_cdec_HypergraphEdge *)o);
p->__pyx_vtab = __pyx_vtabptr_5_cdec_HypergraphEdge;
- p->trule = ((struct __pyx_obj_5_cdec_BaseTRule *)Py_None); Py_INCREF(Py_None);
+ p->trule = ((struct __pyx_obj_5_cdec_TRule *)Py_None); Py_INCREF(Py_None);
return o;
}
@@ -19157,36 +20008,36 @@ static int __pyx_tp_clear_5_cdec_HypergraphEdge(PyObject *o) {
struct __pyx_obj_5_cdec_HypergraphEdge *p = (struct __pyx_obj_5_cdec_HypergraphEdge *)o;
PyObject* tmp;
tmp = ((PyObject*)p->trule);
- p->trule = ((struct __pyx_obj_5_cdec_BaseTRule *)Py_None); Py_INCREF(Py_None);
+ p->trule = ((struct __pyx_obj_5_cdec_TRule *)Py_None); Py_INCREF(Py_None);
Py_XDECREF(tmp);
return 0;
}
-static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_head_node(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_head_node(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_14HypergraphEdge_9head_node_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_tail_nodes(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_tail_nodes(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_14HypergraphEdge_10tail_nodes_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_span(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_span(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_14HypergraphEdge_4span_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_feature_values(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_feature_values(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_14HypergraphEdge_14feature_values_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_prob(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_prob(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_14HypergraphEdge_4prob_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_trule(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_trule(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_14HypergraphEdge_5trule_1__get__(o);
}
-static int __pyx_setprop_5_cdec_14HypergraphEdge_trule(PyObject *o, PyObject *v, void *x) {
+static int __pyx_setprop_5_cdec_14HypergraphEdge_trule(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
if (v) {
return __pyx_pw_5_cdec_14HypergraphEdge_5trule_3__set__(o, v);
}
@@ -19364,7 +20215,7 @@ static PyTypeObject __pyx_type_5_cdec_HypergraphEdge = {
};
static struct __pyx_vtabstruct_5_cdec_HypergraphNode __pyx_vtable_5_cdec_HypergraphNode;
-static PyObject *__pyx_tp_new_5_cdec_HypergraphNode(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec_HypergraphNode(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec_HypergraphNode *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -19377,19 +20228,19 @@ static void __pyx_tp_dealloc_5_cdec_HypergraphNode(PyObject *o) {
(*Py_TYPE(o)->tp_free)(o);
}
-static PyObject *__pyx_getprop_5_cdec_14HypergraphNode_in_edges(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_14HypergraphNode_in_edges(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_14HypergraphNode_8in_edges_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_14HypergraphNode_out_edges(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_14HypergraphNode_out_edges(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_14HypergraphNode_9out_edges_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_14HypergraphNode_span(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_14HypergraphNode_span(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_14HypergraphNode_4span_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_14HypergraphNode_cat(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_14HypergraphNode_cat(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_14HypergraphNode_3cat_1__get__(o);
}
@@ -19573,7 +20424,7 @@ static void __pyx_tp_dealloc_5_cdec_Lattice(PyObject *o) {
PyObject *etype, *eval, *etb;
PyErr_Fetch(&etype, &eval, &etb);
++Py_REFCNT(o);
- __pyx_pw_5_cdec_7Lattice_14__dealloc__(o);
+ __pyx_pw_5_cdec_7Lattice_3__dealloc__(o);
if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
--Py_REFCNT(o);
PyErr_Restore(etype, eval, etb);
@@ -19590,7 +20441,7 @@ static PyObject *__pyx_sq_item_5_cdec_Lattice(PyObject *o, Py_ssize_t i) {
static int __pyx_mp_ass_subscript_5_cdec_Lattice(PyObject *o, PyObject *i, PyObject *v) {
if (v) {
- return __pyx_pw_5_cdec_7Lattice_5__setitem__(o, i, v);
+ return __pyx_pw_5_cdec_7Lattice_7__setitem__(o, i, v);
}
else {
PyErr_Format(PyExc_NotImplementedError,
@@ -19663,7 +20514,7 @@ static PyNumberMethods __pyx_tp_as_number_Lattice = {
};
static PySequenceMethods __pyx_tp_as_sequence_Lattice = {
- __pyx_pw_5_cdec_7Lattice_7__len__, /*sq_length*/
+ __pyx_pw_5_cdec_7Lattice_9__len__, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
__pyx_sq_item_5_cdec_Lattice, /*sq_item*/
@@ -19676,8 +20527,8 @@ static PySequenceMethods __pyx_tp_as_sequence_Lattice = {
};
static PyMappingMethods __pyx_tp_as_mapping_Lattice = {
- __pyx_pw_5_cdec_7Lattice_7__len__, /*mp_length*/
- __pyx_pw_5_cdec_7Lattice_3__getitem__, /*mp_subscript*/
+ __pyx_pw_5_cdec_7Lattice_9__len__, /*mp_length*/
+ __pyx_pw_5_cdec_7Lattice_5__getitem__, /*mp_subscript*/
__pyx_mp_ass_subscript_5_cdec_Lattice, /*mp_ass_subscript*/
};
@@ -19722,7 +20573,7 @@ static PyTypeObject __pyx_type_5_cdec_Lattice = {
&__pyx_tp_as_mapping_Lattice, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
- __pyx_pw_5_cdec_7Lattice_9__str__, /*tp_str*/
+ __pyx_pw_5_cdec_7Lattice_11__str__, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
&__pyx_tp_as_buffer_Lattice, /*tp_as_buffer*/
@@ -19732,7 +20583,7 @@ static PyTypeObject __pyx_type_5_cdec_Lattice = {
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
- __pyx_pw_5_cdec_7Lattice_11__iter__, /*tp_iter*/
+ __pyx_pw_5_cdec_7Lattice_13__iter__, /*tp_iter*/
0, /*tp_iternext*/
__pyx_methods_5_cdec_Lattice, /*tp_methods*/
0, /*tp_members*/
@@ -19758,7 +20609,7 @@ static PyTypeObject __pyx_type_5_cdec_Lattice = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec_Candidate(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec_Candidate(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
return o;
@@ -19768,19 +20619,19 @@ static void __pyx_tp_dealloc_5_cdec_Candidate(PyObject *o) {
(*Py_TYPE(o)->tp_free)(o);
}
-static PyObject *__pyx_getprop_5_cdec_9Candidate_words(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_9Candidate_words(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_9Candidate_5words_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_9Candidate_fmap(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_9Candidate_fmap(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_9Candidate_4fmap_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_9Candidate_score(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_9Candidate_score(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_9Candidate_5score_1__get__(o);
}
-static int __pyx_setprop_5_cdec_9Candidate_score(PyObject *o, PyObject *v, void *x) {
+static int __pyx_setprop_5_cdec_9Candidate_score(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
if (v) {
return __pyx_pw_5_cdec_9Candidate_5score_3__set__(o, v);
}
@@ -19955,7 +20806,7 @@ static PyTypeObject __pyx_type_5_cdec_Candidate = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec_SufficientStats(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec_SufficientStats(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
return o;
@@ -19981,11 +20832,11 @@ static PyObject *__pyx_sq_item_5_cdec_SufficientStats(PyObject *o, Py_ssize_t i)
return r;
}
-static PyObject *__pyx_getprop_5_cdec_15SufficientStats_score(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_15SufficientStats_score(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_15SufficientStats_5score_1__get__(o);
}
-static PyObject *__pyx_getprop_5_cdec_15SufficientStats_detail(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_15SufficientStats_detail(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_15SufficientStats_6detail_1__get__(o);
}
@@ -20341,7 +21192,7 @@ static PyTypeObject __pyx_type_5_cdec_CandidateSet = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec_SegmentEvaluator(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec_SegmentEvaluator(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
return o;
@@ -20700,7 +21551,7 @@ static PyTypeObject __pyx_type_5_cdec_Scorer = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec_Metric(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec_Metric(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec_Metric *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -20941,11 +21792,11 @@ static int __pyx_tp_clear_5_cdec_Decoder(PyObject *o) {
return 0;
}
-static PyObject *__pyx_getprop_5_cdec_7Decoder_weights(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_7Decoder_weights(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_7Decoder_7weights_1__get__(o);
}
-static int __pyx_setprop_5_cdec_7Decoder_weights(PyObject *o, PyObject *v, void *x) {
+static int __pyx_setprop_5_cdec_7Decoder_weights(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
if (v) {
return __pyx_pw_5_cdec_7Decoder_7weights_3__set__(o, v);
}
@@ -20955,7 +21806,7 @@ static int __pyx_setprop_5_cdec_7Decoder_weights(PyObject *o, PyObject *v, void
}
}
-static PyObject *__pyx_getprop_5_cdec_7Decoder_formalism(PyObject *o, void *x) {
+static PyObject *__pyx_getprop_5_cdec_7Decoder_formalism(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_5_cdec_7Decoder_9formalism_1__get__(o);
}
@@ -21125,7 +21976,7 @@ static PyTypeObject __pyx_type_5_cdec_Decoder = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct____iter__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct____iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -21316,7 +22167,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct____iter__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_1___iter__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_1___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -21507,7 +22358,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_1___iter__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_2__phrase(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_2__phrase(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -21698,7 +22549,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_2__phrase = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_3_genexpr(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_3_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -21905,7 +22756,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_3_genexpr = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_4___get__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_4___get__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -21933,7 +22784,7 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_4___get__(PyObject *o) {
struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *)o;
PyObject* tmp;
tmp = ((PyObject*)p->__pyx_v_self);
- p->__pyx_v_self = ((struct __pyx_obj_5_cdec_BaseTRule *)Py_None); Py_INCREF(Py_None);
+ p->__pyx_v_self = ((struct __pyx_obj_5_cdec_TRule *)Py_None); Py_INCREF(Py_None);
Py_XDECREF(tmp);
return 0;
}
@@ -22096,7 +22947,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_4___get__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_5___str__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_5___str__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -22124,7 +22975,7 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_5___str__(PyObject *o) {
struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *)o;
PyObject* tmp;
tmp = ((PyObject*)p->__pyx_v_self);
- p->__pyx_v_self = ((struct __pyx_obj_5_cdec_BaseTRule *)Py_None); Py_INCREF(Py_None);
+ p->__pyx_v_self = ((struct __pyx_obj_5_cdec_TRule *)Py_None); Py_INCREF(Py_None);
Py_XDECREF(tmp);
return 0;
}
@@ -22287,7 +23138,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_5___str__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_6_genexpr(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_6_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -22494,7 +23345,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_6_genexpr = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_7___iter__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_7___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -22693,7 +23544,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_7___iter__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_8_kbest(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_8_kbest(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -22892,7 +23743,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_8_kbest = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_9_kbest_trees(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_9_kbest_trees(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -23107,7 +23958,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_9_kbest_trees = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_10_kbest_features(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_10_kbest_features(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -23314,7 +24165,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_10_kbest_features = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_11_sample(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_11_sample(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -23505,7 +24356,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_11_sample = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_12___get__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_12___get__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -23696,7 +24547,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_12___get__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_13___get__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_13___get__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -23887,7 +24738,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_13___get__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_14___get__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_14___get__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -24078,7 +24929,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_14___get__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_15___get__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_15___get__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -24269,7 +25120,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_15___get__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_16___get__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_16___get__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -24460,7 +25311,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_16___get__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_17___iter__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_17___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -24651,7 +25502,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_17___iter__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_18_todot(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_18_todot(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -24842,7 +25693,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_18_todot = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_19_lines(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_19_lines(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -25081,7 +25932,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_19_lines = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_20___iter__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_20___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -25288,7 +26139,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_20___iter__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_21___iter__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_21___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -25479,7 +26330,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_21___iter__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_22__make_config(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_22__make_config(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -25718,7 +26569,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_22__make_config = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_23___cinit__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_23___cinit__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -25909,7 +26760,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_23___cinit__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_24_genexpr(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_24_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -26135,7 +26986,6 @@ static struct PyModuleDef __pyx_moduledef = {
#endif
static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
{&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
{&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
{&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
@@ -26166,8 +27016,10 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_kp_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 0},
{&__pyx_kp_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 0},
{&__pyx_kp_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 0},
- {&__pyx_kp_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 0},
- {&__pyx_kp_s_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 0, 1, 0},
+ {&__pyx_n_s_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 0, 1, 1},
+ {&__pyx_n_s_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 1, 1},
+ {&__pyx_kp_s_58, __pyx_k_58, sizeof(__pyx_k_58), 0, 0, 1, 0},
+ {&__pyx_kp_s_64, __pyx_k_64, sizeof(__pyx_k_64), 0, 0, 1, 0},
{&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
{&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
{&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
@@ -26180,6 +27032,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
{&__pyx_n_s__NotImplemented, __pyx_k__NotImplemented, sizeof(__pyx_k__NotImplemented), 0, 0, 1, 1},
{&__pyx_n_s__ParseFailed, __pyx_k__ParseFailed, sizeof(__pyx_k__ParseFailed), 0, 0, 1, 1},
+ {&__pyx_n_s__PhraseModel_, __pyx_k__PhraseModel_, sizeof(__pyx_k__PhraseModel_), 0, 0, 1, 1},
{&__pyx_n_s__TER, __pyx_k__TER, sizeof(__pyx_k__TER), 0, 0, 1, 1},
{&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
{&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
@@ -26192,6 +27045,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s___cdec, __pyx_k___cdec, sizeof(__pyx_k___cdec), 0, 0, 1, 1},
{&__pyx_n_s___make_config, __pyx_k___make_config, sizeof(__pyx_k___make_config), 0, 0, 1, 1},
{&__pyx_n_s___phrase, __pyx_k___phrase, sizeof(__pyx_k___phrase), 0, 0, 1, 1},
+ {&__pyx_n_s___sa, __pyx_k___sa, sizeof(__pyx_k___sa), 0, 0, 1, 1},
{&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1},
{&__pyx_n_s__beam_alpha, __pyx_k__beam_alpha, sizeof(__pyx_k__beam_alpha), 0, 0, 1, 1},
{&__pyx_n_s__cat, __pyx_k__cat, sizeof(__pyx_k__cat), 0, 0, 1, 1},
@@ -26210,6 +27064,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s__evaluator, __pyx_k__evaluator, sizeof(__pyx_k__evaluator), 0, 0, 1, 1},
{&__pyx_n_s__f, __pyx_k__f, sizeof(__pyx_k__f), 0, 0, 1, 1},
{&__pyx_n_s__formalism, __pyx_k__formalism, sizeof(__pyx_k__formalism), 0, 0, 1, 1},
+ {&__pyx_n_s__format, __pyx_k__format, sizeof(__pyx_k__format), 0, 0, 1, 1},
{&__pyx_n_s__fst, __pyx_k__fst, sizeof(__pyx_k__fst), 0, 0, 1, 1},
{&__pyx_n_s__genexpr, __pyx_k__genexpr, sizeof(__pyx_k__genexpr), 0, 0, 1, 1},
{&__pyx_n_s__get, __pyx_k__get, sizeof(__pyx_k__get), 0, 0, 1, 1},
@@ -26257,14 +27112,14 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
static int __Pyx_InitCachedBuiltins(void) {
__pyx_builtin_Exception = __Pyx_GetName(__pyx_b, __pyx_n_s__Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 13; __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 = 24; __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 = 77; __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 = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __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_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 = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_builtin_open = __Pyx_GetName(__pyx_b, __pyx_n_s__open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __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;}
+ __pyx_builtin_open = __Pyx_GetName(__pyx_b, __pyx_n_s__open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
return 0;
__pyx_L1_error:;
return -1;
@@ -26288,41 +27143,41 @@ static int __Pyx_InitCachedConstants(void) {
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2));
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":77
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":89
* elif op == 3: # !=
* return not (x == y)
* raise NotImplemented('comparison not implemented for SparseVector') # <<<<<<<<<<<<<<
*
* def __len__(self):
*/
- __pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_k_tuple_5);
__Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, ((PyObject *)__pyx_kp_s_4));
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5));
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":4
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":6
*
* def _phrase(phrase):
* return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) # <<<<<<<<<<<<<<
*
* cdef class NT:
*/
- __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_k_tuple_6);
__Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
PyTuple_SET_ITEM(__pyx_k_tuple_6, 0, ((PyObject *)__pyx_n_s__utf8));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6));
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":175
- * for trule in rules:
- * if not isinstance(trule, BaseTRule):
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":200
+ * trule = convert_rule(trule)
+ * elif not isinstance(trule, TRule):
* raise ValueError('the grammar should contain TRule objects') # <<<<<<<<<<<<<<
- * _g.AddRule((<BaseTRule> trule).rule[0])
+ * _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 = 175; __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 = 200; __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));
@@ -26369,42 +27224,42 @@ static int __Pyx_InitCachedConstants(void) {
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21));
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":21
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":24
* def __getitem__(self, int index):
* if not 0 <= index < len(self):
* raise IndexError('lattice index out of range') # <<<<<<<<<<<<<<
* arcs = []
* cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index]
*/
- __pyx_k_tuple_24 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_24)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_k_tuple_24 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_24)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_k_tuple_24);
__Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
PyTuple_SET_ITEM(__pyx_k_tuple_24, 0, ((PyObject *)__pyx_kp_s_23));
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_24));
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":34
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":37
* def __setitem__(self, int index, tuple arcs):
* if not 0 <= index < len(self):
* raise IndexError('lattice index out of range') # <<<<<<<<<<<<<<
* cdef lattice.LatticeArc* arc
* for (label, cost, dist2next) in arcs:
*/
- __pyx_k_tuple_25 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_k_tuple_25 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_k_tuple_25);
__Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, ((PyObject *)__pyx_kp_s_23));
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25));
- /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":38
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":41
* for (label, cost, dist2next) in arcs:
* if isinstance(label, unicode):
* label = label.encode('utf8') # <<<<<<<<<<<<<<
* arc = new lattice.LatticeArc(TDConvert(<char *>label), cost, dist2next)
* self.lattice[0][index].push_back(arc[0])
*/
- __pyx_k_tuple_26 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_26)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_k_tuple_26 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_26)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_k_tuple_26);
__Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
PyTuple_SET_ITEM(__pyx_k_tuple_26, 0, ((PyObject *)__pyx_n_s__utf8));
@@ -26509,28 +27364,28 @@ static int __Pyx_InitCachedConstants(void) {
__Pyx_GIVEREF(Py_None);
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_47));
- /* "_cdec.pyx":88
+ /* "_cdec.pyx":90
* with open(weights) as fp:
* for line in fp:
* if line.strip().startswith('#'): continue # <<<<<<<<<<<<<<
* fname, value = line.split()
* self.weights[fname.strip()] = float(value)
*/
- __pyx_k_tuple_51 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_k_tuple_51 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_k_tuple_51);
__Pyx_INCREF(((PyObject *)__pyx_kp_s_50));
PyTuple_SET_ITEM(__pyx_k_tuple_51, 0, ((PyObject *)__pyx_kp_s_50));
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_50));
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51));
- /* "_cdec.pyx":86
+ /* "_cdec.pyx":88
*
* def read_weights(self, weights):
* with open(weights) as fp: # <<<<<<<<<<<<<<
* for line in fp:
* if line.strip().startswith('#'): continue
*/
- __pyx_k_tuple_52 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_k_tuple_52 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_k_tuple_52);
__Pyx_INCREF(Py_None);
PyTuple_SET_ITEM(__pyx_k_tuple_52, 0, Py_None);
@@ -26543,26 +27398,26 @@ static int __Pyx_InitCachedConstants(void) {
__Pyx_GIVEREF(Py_None);
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_52));
- /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":3
- * cimport grammar
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5
+ * import cdec.sa._sa as _sa
*
* def _phrase(phrase): # <<<<<<<<<<<<<<
* return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase)
*
*/
- __pyx_k_tuple_54 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_54)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_54);
+ __pyx_k_tuple_56 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_56)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_56);
__Pyx_INCREF(((PyObject *)__pyx_n_s__phrase));
- PyTuple_SET_ITEM(__pyx_k_tuple_54, 0, ((PyObject *)__pyx_n_s__phrase));
+ PyTuple_SET_ITEM(__pyx_k_tuple_56, 0, ((PyObject *)__pyx_n_s__phrase));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__phrase));
__Pyx_INCREF(((PyObject *)__pyx_n_s__genexpr));
- PyTuple_SET_ITEM(__pyx_k_tuple_54, 1, ((PyObject *)__pyx_n_s__genexpr));
+ PyTuple_SET_ITEM(__pyx_k_tuple_56, 1, ((PyObject *)__pyx_n_s__genexpr));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__genexpr));
__Pyx_INCREF(((PyObject *)__pyx_n_s__genexpr));
- PyTuple_SET_ITEM(__pyx_k_tuple_54, 2, ((PyObject *)__pyx_n_s__genexpr));
+ PyTuple_SET_ITEM(__pyx_k_tuple_56, 2, ((PyObject *)__pyx_n_s__genexpr));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__genexpr));
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_54));
- __pyx_k_codeobj_55 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_54, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_56, __pyx_n_s___phrase, 3, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_55)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_56));
+ __pyx_k_codeobj_57 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_56, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_58, __pyx_n_s___phrase, 5, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_57)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":190
* return []
@@ -26571,12 +27426,12 @@ static int __Pyx_InitCachedConstants(void) {
* TER = Scorer('TER')
* CER = Scorer('CER')
*/
- __pyx_k_tuple_57 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_57)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_57);
+ __pyx_k_tuple_59 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_59)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_59);
__Pyx_INCREF(((PyObject *)__pyx_n_s__IBM_BLEU));
- PyTuple_SET_ITEM(__pyx_k_tuple_57, 0, ((PyObject *)__pyx_n_s__IBM_BLEU));
+ PyTuple_SET_ITEM(__pyx_k_tuple_59, 0, ((PyObject *)__pyx_n_s__IBM_BLEU));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__IBM_BLEU));
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_57));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_59));
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":191
*
@@ -26584,24 +27439,24 @@ static int __Pyx_InitCachedConstants(void) {
* TER = Scorer('TER') # <<<<<<<<<<<<<<
* CER = Scorer('CER')
*/
- __pyx_k_tuple_58 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_58)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_58);
+ __pyx_k_tuple_60 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_60)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_60);
__Pyx_INCREF(((PyObject *)__pyx_n_s__TER));
- PyTuple_SET_ITEM(__pyx_k_tuple_58, 0, ((PyObject *)__pyx_n_s__TER));
+ PyTuple_SET_ITEM(__pyx_k_tuple_60, 0, ((PyObject *)__pyx_n_s__TER));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__TER));
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_58));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60));
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":192
* BLEU = Scorer('IBM_BLEU')
* TER = Scorer('TER')
* CER = Scorer('CER') # <<<<<<<<<<<<<<
*/
- __pyx_k_tuple_59 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_59)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_59);
+ __pyx_k_tuple_61 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_61)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_61);
__Pyx_INCREF(((PyObject *)__pyx_n_s__CER));
- PyTuple_SET_ITEM(__pyx_k_tuple_59, 0, ((PyObject *)__pyx_n_s__CER));
+ PyTuple_SET_ITEM(__pyx_k_tuple_61, 0, ((PyObject *)__pyx_n_s__CER));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__CER));
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_59));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61));
/* "_cdec.pyx":28
* class ParseFailed(Exception): pass
@@ -26610,25 +27465,25 @@ static int __Pyx_InitCachedConstants(void) {
* for key, value in config.items():
* if isinstance(value, dict):
*/
- __pyx_k_tuple_60 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_60);
+ __pyx_k_tuple_62 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_62);
__Pyx_INCREF(((PyObject *)__pyx_n_s__config));
- PyTuple_SET_ITEM(__pyx_k_tuple_60, 0, ((PyObject *)__pyx_n_s__config));
+ PyTuple_SET_ITEM(__pyx_k_tuple_62, 0, ((PyObject *)__pyx_n_s__config));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__config));
__Pyx_INCREF(((PyObject *)__pyx_n_s__key));
- PyTuple_SET_ITEM(__pyx_k_tuple_60, 1, ((PyObject *)__pyx_n_s__key));
+ PyTuple_SET_ITEM(__pyx_k_tuple_62, 1, ((PyObject *)__pyx_n_s__key));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__key));
__Pyx_INCREF(((PyObject *)__pyx_n_s__value));
- PyTuple_SET_ITEM(__pyx_k_tuple_60, 2, ((PyObject *)__pyx_n_s__value));
+ PyTuple_SET_ITEM(__pyx_k_tuple_62, 2, ((PyObject *)__pyx_n_s__value));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__value));
__Pyx_INCREF(((PyObject *)__pyx_n_s__name));
- PyTuple_SET_ITEM(__pyx_k_tuple_60, 3, ((PyObject *)__pyx_n_s__name));
+ PyTuple_SET_ITEM(__pyx_k_tuple_62, 3, ((PyObject *)__pyx_n_s__name));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
__Pyx_INCREF(((PyObject *)__pyx_n_s__info));
- PyTuple_SET_ITEM(__pyx_k_tuple_60, 4, ((PyObject *)__pyx_n_s__info));
+ PyTuple_SET_ITEM(__pyx_k_tuple_62, 4, ((PyObject *)__pyx_n_s__info));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__info));
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60));
- __pyx_k_codeobj_61 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_60, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_62, __pyx_n_s___make_config, 28, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_62));
+ __pyx_k_codeobj_63 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_62, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_64, __pyx_n_s___make_config, 28, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_RefNannyFinishContext();
return 0;
__pyx_L1_error:;
@@ -26640,6 +27495,7 @@ static int __Pyx_InitGlobals(void) {
if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ __pyx_int_65536 = PyInt_FromLong(65536); if (unlikely(!__pyx_int_65536)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
return 0;
__pyx_L1_error:;
return -1;
@@ -26656,6 +27512,7 @@ PyMODINIT_FUNC PyInit__cdec(void)
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
+ PyObject *__pyx_t_4 = NULL;
__Pyx_RefNannyDeclarations
#if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
@@ -26698,6 +27555,9 @@ PyMODINIT_FUNC PyInit__cdec(void)
#endif
__pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #if CYTHON_COMPILING_IN_PYPY
+ Py_INCREF(__pyx_b);
+ #endif
if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
/*--- Initialize various global constants etc. ---*/
if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -26715,28 +27575,24 @@ PyMODINIT_FUNC PyInit__cdec(void)
if (PyType_Ready(&__pyx_type_5_cdec_DenseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__Pyx_SetAttrString(__pyx_m, "DenseVector", (PyObject *)&__pyx_type_5_cdec_DenseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec_DenseVector = &__pyx_type_5_cdec_DenseVector;
- if (PyType_Ready(&__pyx_type_5_cdec_SparseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "SparseVector", (PyObject *)&__pyx_type_5_cdec_SparseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec_SparseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "SparseVector", (PyObject *)&__pyx_type_5_cdec_SparseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec_SparseVector = &__pyx_type_5_cdec_SparseVector;
- if (PyType_Ready(&__pyx_type_5_cdec_NT) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "NT", (PyObject *)&__pyx_type_5_cdec_NT) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec_NT) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "NT", (PyObject *)&__pyx_type_5_cdec_NT) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec_NT = &__pyx_type_5_cdec_NT;
- if (PyType_Ready(&__pyx_type_5_cdec_NTRef) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "NTRef", (PyObject *)&__pyx_type_5_cdec_NTRef) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec_NTRef) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "NTRef", (PyObject *)&__pyx_type_5_cdec_NTRef) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec_NTRef = &__pyx_type_5_cdec_NTRef;
- if (PyType_Ready(&__pyx_type_5_cdec_BaseTRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "BaseTRule", (PyObject *)&__pyx_type_5_cdec_BaseTRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_ptype_5_cdec_BaseTRule = &__pyx_type_5_cdec_BaseTRule;
- __pyx_type_5_cdec_TRule.tp_base = __pyx_ptype_5_cdec_BaseTRule;
- if (PyType_Ready(&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 135; __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 = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ 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 = 146; __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 = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ 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_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 = 169; __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 = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ 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;}
__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;}
@@ -26777,21 +27633,21 @@ PyMODINIT_FUNC PyInit__cdec(void)
if (PyType_Ready(&__pyx_type_5_cdec_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__Pyx_SetAttrString(__pyx_m, "Decoder", (PyObject *)&__pyx_type_5_cdec_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec_Decoder = &__pyx_type_5_cdec_Decoder;
- if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct____iter__) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct____iter__) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec___pyx_scope_struct____iter__ = &__pyx_type_5_cdec___pyx_scope_struct____iter__;
- if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_1___iter__) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_1___iter__) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec___pyx_scope_struct_1___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_1___iter__;
- if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_2__phrase) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_2__phrase) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec___pyx_scope_struct_2__phrase = &__pyx_type_5_cdec___pyx_scope_struct_2__phrase;
- if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_3_genexpr) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_3_genexpr) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec___pyx_scope_struct_3_genexpr = &__pyx_type_5_cdec___pyx_scope_struct_3_genexpr;
- if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_4___get__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_4___get__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec___pyx_scope_struct_4___get__ = &__pyx_type_5_cdec___pyx_scope_struct_4___get__;
- if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_5___str__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_5___str__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__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 = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ 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 = 152; __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 = 175; __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;
@@ -26811,7 +27667,7 @@ PyMODINIT_FUNC PyInit__cdec(void)
__pyx_ptype_5_cdec___pyx_scope_struct_15___get__ = &__pyx_type_5_cdec___pyx_scope_struct_15___get__;
if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_16___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec___pyx_scope_struct_16___get__ = &__pyx_type_5_cdec___pyx_scope_struct_16___get__;
- if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_17___iter__) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_17___iter__) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec___pyx_scope_struct_17___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_17___iter__;
if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_18_todot) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec___pyx_scope_struct_18_todot = &__pyx_type_5_cdec___pyx_scope_struct_18_todot;
@@ -26828,21 +27684,48 @@ PyMODINIT_FUNC PyInit__cdec(void)
if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_24_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec___pyx_scope_struct_24_genexpr = &__pyx_type_5_cdec___pyx_scope_struct_24_genexpr;
/*--- Type import code ---*/
+ __pyx_ptype_4cdec_2sa_3_sa_Phrase = __Pyx_ImportType("cdec.sa._sa", "Phrase", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Phrase), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_vtabptr_4cdec_2sa_3_sa_Phrase = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_Phrase->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_4cdec_2sa_3_sa_Rule = __Pyx_ImportType("cdec.sa._sa", "Rule", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Rule), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Rule)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/*--- Variable import code ---*/
/*--- Function import code ---*/
+ __pyx_t_1 = __Pyx_ImportModule("cdec.sa._sa"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_ImportFunction(__pyx_t_1, "sym_tostring", (void (**)(void))&__pyx_f_4cdec_2sa_3_sa_sym_tostring, "char *(int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_ImportFunction(__pyx_t_1, "sym_tocat", (void (**)(void))&__pyx_f_4cdec_2sa_3_sa_sym_tocat, "char *(int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_ImportFunction(__pyx_t_1, "sym_isvar", (void (**)(void))&__pyx_f_4cdec_2sa_3_sa_sym_isvar, "int (int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_ImportFunction(__pyx_t_1, "sym_getindex", (void (**)(void))&__pyx_f_4cdec_2sa_3_sa_sym_getindex, "int (int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/*--- Execution code ---*/
/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":3
* cimport grammar
+ * cimport cdec.sa._sa as _sa
+ * import cdec.sa._sa as _sa # <<<<<<<<<<<<<<
+ *
+ * def _phrase(phrase):
+ */
+ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_INCREF(((PyObject *)__pyx_n_s_55));
+ PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s_55));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s_55));
+ __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s_54), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s___sa, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5
+ * import cdec.sa._sa as _sa
*
* def _phrase(phrase): # <<<<<<<<<<<<<<
* return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase)
*
*/
- __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5_cdec_1_phrase, NULL, __pyx_n_s___cdec); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s___phrase, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_5_cdec_1_phrase, NULL, __pyx_n_s___cdec); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s___phrase, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":190
* return []
@@ -26851,10 +27734,10 @@ PyMODINIT_FUNC PyInit__cdec(void)
* TER = Scorer('TER')
* CER = Scorer('CER')
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_57), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s__BLEU, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_59), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s__BLEU, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":191
*
@@ -26862,20 +27745,20 @@ PyMODINIT_FUNC PyInit__cdec(void)
* TER = Scorer('TER') # <<<<<<<<<<<<<<
* CER = Scorer('CER')
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_58), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s__TER, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_60), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s__TER, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":192
* BLEU = Scorer('IBM_BLEU')
* TER = Scorer('TER')
* CER = Scorer('CER') # <<<<<<<<<<<<<<
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_59), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s__CER, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_61), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s__CER, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "_cdec.pyx":22
* include "mteval.pxi"
@@ -26902,19 +27785,19 @@ PyMODINIT_FUNC PyInit__cdec(void)
* class ParseFailed(Exception): pass
*
*/
- __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_3));
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(__pyx_builtin_Exception);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_Exception);
__Pyx_GIVEREF(__pyx_builtin_Exception);
- __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s__InvalidConfig, __pyx_n_s___cdec); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_4 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3), __pyx_n_s__InvalidConfig, __pyx_n_s___cdec); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s__InvalidConfig, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s__InvalidConfig, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
/* "_cdec.pyx":26
*
@@ -26923,19 +27806,19 @@ PyMODINIT_FUNC PyInit__cdec(void)
*
* def _make_config(config):
*/
- __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(((PyObject *)__pyx_t_1));
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
__Pyx_INCREF(__pyx_builtin_Exception);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_builtin_Exception);
+ PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_builtin_Exception);
__Pyx_GIVEREF(__pyx_builtin_Exception);
- __pyx_t_2 = __Pyx_CreateClass(((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1), __pyx_n_s__ParseFailed, __pyx_n_s___cdec); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = __Pyx_CreateClass(((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_3), __pyx_n_s__ParseFailed, __pyx_n_s___cdec); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ParseFailed, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
/* "_cdec.pyx":28
* class ParseFailed(Exception): pass
@@ -26944,25 +27827,34 @@ PyMODINIT_FUNC PyInit__cdec(void)
* for key, value in config.items():
* if isinstance(value, dict):
*/
- __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5_cdec_3_make_config, NULL, __pyx_n_s___cdec); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s___make_config, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_5_cdec_3_make_config, NULL, __pyx_n_s___cdec); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s___make_config, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "_cdec.pyx":1
* from libcpp.string cimport string # <<<<<<<<<<<<<<
* from libcpp.vector cimport vector
* from utils cimport *
*/
- __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(((PyObject *)__pyx_t_1));
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+ __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+
+ /* "string.to_py":25
+ *
+ * @cname("__pyx_convert_string_to_py_")
+ * cdef object __pyx_convert_string_to_py_(string& s): # <<<<<<<<<<<<<<
+ * return s.data()[:s.size()]
+ *
+ */
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
if (__pyx_m) {
__Pyx_AddTraceback("init _cdec", __pyx_clineno, __pyx_lineno, __pyx_filename);
Py_DECREF(__pyx_m); __pyx_m = 0;
@@ -27163,6 +28055,71 @@ bad:
}
#endif
+static void __Pyx_RaiseArgtupleInvalid(
+ const char* func_name,
+ int exact,
+ Py_ssize_t num_min,
+ Py_ssize_t num_max,
+ Py_ssize_t num_found)
+{
+ Py_ssize_t num_expected;
+ const char *more_or_less;
+ if (num_found < num_min) {
+ num_expected = num_min;
+ more_or_less = "at least";
+ } else {
+ num_expected = num_max;
+ more_or_less = "at most";
+ }
+ if (exact) {
+ more_or_less = "exactly";
+ }
+ PyErr_Format(PyExc_TypeError,
+ "%s() takes %s %" PY_FORMAT_SIZE_T "d positional argument%s (%" PY_FORMAT_SIZE_T "d given)",
+ func_name, more_or_less, num_expected,
+ (num_expected == 1) ? "" : "s", num_found);
+}
+
+static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
+ PyObject *kwdict,
+ const char* function_name,
+ int kw_allowed)
+{
+ PyObject* key = 0;
+ Py_ssize_t pos = 0;
+#if CPYTHON_COMPILING_IN_PYPY
+ if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
+ goto invalid_keyword;
+ return 1;
+#else
+ while (PyDict_Next(kwdict, &pos, &key, 0)) {
+ #if PY_MAJOR_VERSION < 3
+ if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
+ #else
+ if (unlikely(!PyUnicode_Check(key)))
+ #endif
+ goto invalid_keyword_type;
+ }
+ if ((!kw_allowed) && unlikely(key))
+ goto invalid_keyword;
+ return 1;
+invalid_keyword_type:
+ PyErr_Format(PyExc_TypeError,
+ "%s() keywords must be strings", function_name);
+ return 0;
+#endif
+invalid_keyword:
+ PyErr_Format(PyExc_TypeError,
+ #if PY_MAJOR_VERSION < 3
+ "%s() got an unexpected keyword argument '%s'",
+ function_name, PyString_AsString(key));
+ #else
+ "%s() got an unexpected keyword argument '%U'",
+ function_name, key);
+ #endif
+ return 0;
+}
+
static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
const char *name, int exact)
{
@@ -27289,42 +28246,49 @@ bad:
return -1;
}
-static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
+static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
+ PyErr_Format(PyExc_ValueError,
+ "too many values to unpack (expected %" PY_FORMAT_SIZE_T "d)", expected);
}
-
-
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
PyErr_Format(PyExc_ValueError,
- "need more than %"PY_FORMAT_SIZE_T"d value%s to unpack",
+ "need more than %" PY_FORMAT_SIZE_T "d value%s to unpack",
index, (index == 1) ? "" : "s");
}
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
- PyErr_Format(PyExc_ValueError,
- "too many values to unpack (expected %"PY_FORMAT_SIZE_T"d)", expected);
+static CYTHON_INLINE int __Pyx_IterFinish(void) {
+#if CYTHON_COMPILING_IN_CPYTHON
+ PyThreadState *tstate = PyThreadState_GET();
+ PyObject* exc_type = tstate->curexc_type;
+ if (unlikely(exc_type)) {
+ if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
+ PyObject *exc_value, *exc_tb;
+ exc_value = tstate->curexc_value;
+ exc_tb = tstate->curexc_traceback;
+ tstate->curexc_type = 0;
+ tstate->curexc_value = 0;
+ tstate->curexc_traceback = 0;
+ Py_DECREF(exc_type);
+ Py_XDECREF(exc_value);
+ Py_XDECREF(exc_tb);
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+ return 0;
+#else
+ if (unlikely(PyErr_Occurred())) {
+ if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
+ PyErr_Clear();
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+ return 0;
+#endif
}
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
@@ -27332,79 +28296,54 @@ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
Py_DECREF(retval);
__Pyx_RaiseTooManyValuesError(expected);
return -1;
- } else if (PyErr_Occurred()) {
- if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
- PyErr_Clear();
- return 0;
- } else {
- return -1;
- }
+ } else {
+ return __Pyx_IterFinish();
}
return 0;
}
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
PyObject* next;
- if (unlikely(!PyIter_Check(iterator))) {
+ iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
+#if CYTHON_COMPILING_IN_CPYTHON
+ if (unlikely(!iternext)) {
+#else
+ if (unlikely(!iternext) || unlikely(!PyIter_Check(iterator))) {
+#endif
PyErr_Format(PyExc_TypeError,
- "%.200s object is not an iterator", iterator->ob_type->tp_name);
+ "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
return NULL;
}
- next = (*(Py_TYPE(iterator)->tp_iternext))(iterator);
- if (likely(next)) {
+ next = iternext(iterator);
+ if (likely(next))
return next;
- } else if (defval) {
- if (PyErr_Occurred()) {
- if(!PyErr_ExceptionMatches(PyExc_StopIteration))
+#if CYTHON_COMPILING_IN_CPYTHON
+#if PY_VERSION_HEX >= 0x03010000 || (PY_MAJOR_VERSION < 3 && PY_VERSION_HEX >= 0x02070000)
+ if (unlikely(iternext == &_PyObject_NextNotImplemented))
+ return NULL;
+#endif
+#endif
+ if (defval) {
+ PyObject* exc_type = PyErr_Occurred();
+ if (exc_type) {
+ if (unlikely(exc_type != PyExc_StopIteration) &&
+ !PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))
return NULL;
PyErr_Clear();
}
Py_INCREF(defval);
return defval;
- } else if (PyErr_Occurred()) {
- return NULL;
- } else {
- PyErr_SetNone(PyExc_StopIteration);
- return NULL;
- }
-}
-
-static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
- PyObject *kwdict,
- const char* function_name,
- int kw_allowed)
-{
- PyObject* key = 0;
- Py_ssize_t pos = 0;
- while (PyDict_Next(kwdict, &pos, &key, 0)) {
- #if PY_MAJOR_VERSION < 3
- if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
- #else
- if (unlikely(!PyUnicode_Check(key)))
- #endif
- goto invalid_keyword_type;
}
- if ((!kw_allowed) && unlikely(key))
- goto invalid_keyword;
- return 1;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%s() keywords must be strings", function_name);
- return 0;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%s() got an unexpected keyword argument '%s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
- return 0;
+ if (!PyErr_Occurred())
+ PyErr_SetNone(PyExc_StopIteration);
+ return NULL;
}
static double __Pyx__PyObject_AsDouble(PyObject* obj) {
PyObject* float_value;
+#if CYTHON_COMPILING_IN_PYPY
+ float_value = PyNumber_Float(obj);
+#else
if (Py_TYPE(obj)->tp_as_number && Py_TYPE(obj)->tp_as_number->nb_float) {
return PyFloat_AsDouble(obj);
} else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
@@ -27421,6 +28360,7 @@ static double __Pyx__PyObject_AsDouble(PyObject* obj) {
PyTuple_SET_ITEM(args, 0, 0);
Py_DECREF(args);
}
+#endif
if (likely(float_value)) {
double value = PyFloat_AS_DOUBLE(float_value);
Py_DECREF(float_value);
@@ -27432,6 +28372,7 @@ bad:
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
PyObject *local_type, *local_value, *local_tb;
+#if CYTHON_COMPILING_IN_CPYTHON
PyObject *tmp_type, *tmp_value, *tmp_tb;
PyThreadState *tstate = PyThreadState_GET();
local_type = tstate->curexc_type;
@@ -27440,19 +28381,27 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
tstate->curexc_type = 0;
tstate->curexc_value = 0;
tstate->curexc_traceback = 0;
+#else
+ PyErr_Fetch(&local_type, &local_value, &local_tb);
+#endif
PyErr_NormalizeException(&local_type, &local_value, &local_tb);
+#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(tstate->curexc_type))
+#else
+ if (unlikely(PyErr_Occurred()))
+#endif
goto bad;
#if PY_MAJOR_VERSION >= 3
if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
goto bad;
#endif
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
Py_INCREF(local_type);
Py_INCREF(local_value);
Py_INCREF(local_tb);
+ *type = local_type;
+ *value = local_value;
+ *tb = local_tb;
+#if CYTHON_COMPILING_IN_CPYTHON
tmp_type = tstate->exc_type;
tmp_value = tstate->exc_value;
tmp_tb = tstate->exc_traceback;
@@ -27460,10 +28409,13 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
tstate->exc_value = local_value;
tstate->exc_traceback = local_tb;
/* Make sure tstate is in a consistent state when we XDECREF
- these objects (XDECREF may run arbitrary code). */
+ these objects (DECREF may run arbitrary code). */
Py_XDECREF(tmp_type);
Py_XDECREF(tmp_value);
Py_XDECREF(tmp_tb);
+#else
+ PyErr_SetExcInfo(local_type, local_value, local_tb);
+#endif
return 0;
bad:
*type = 0;
@@ -27476,6 +28428,7 @@ bad:
}
static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
+#if CYTHON_COMPILING_IN_CPYTHON
PyThreadState *tstate = PyThreadState_GET();
*type = tstate->exc_type;
*value = tstate->exc_value;
@@ -27483,8 +28436,12 @@ static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value,
Py_XINCREF(*type);
Py_XINCREF(*value);
Py_XINCREF(*tb);
+#else
+ PyErr_GetExcInfo(type, value, tb);
+#endif
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
+#if CYTHON_COMPILING_IN_CPYTHON
PyObject *tmp_type, *tmp_value, *tmp_tb;
PyThreadState *tstate = PyThreadState_GET();
tmp_type = tstate->exc_type;
@@ -27496,11 +28453,82 @@ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb)
Py_XDECREF(tmp_type);
Py_XDECREF(tmp_value);
Py_XDECREF(tmp_tb);
+#else
+ PyErr_SetExcInfo(type, value, tb);
+#endif
+}
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
+ PyObject *py_import = 0;
+ PyObject *empty_list = 0;
+ PyObject *module = 0;
+ PyObject *global_dict = 0;
+ PyObject *empty_dict = 0;
+ PyObject *list;
+ py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
+ if (!py_import)
+ goto bad;
+ if (from_list)
+ list = from_list;
+ else {
+ empty_list = PyList_New(0);
+ if (!empty_list)
+ goto bad;
+ list = empty_list;
+ }
+ global_dict = PyModule_GetDict(__pyx_m);
+ if (!global_dict)
+ goto bad;
+ empty_dict = PyDict_New();
+ if (!empty_dict)
+ goto bad;
+ #if PY_VERSION_HEX >= 0x02050000
+ {
+ #if PY_MAJOR_VERSION >= 3
+ if (level == -1) {
+ if (strchr(__Pyx_MODULE_NAME, '.')) {
+ /* try package relative import first */
+ PyObject *py_level = PyInt_FromLong(1);
+ if (!py_level)
+ goto bad;
+ module = PyObject_CallFunctionObjArgs(py_import,
+ name, global_dict, empty_dict, list, py_level, NULL);
+ Py_DECREF(py_level);
+ if (!module) {
+ if (!PyErr_ExceptionMatches(PyExc_ImportError))
+ goto bad;
+ PyErr_Clear();
+ }
+ }
+ level = 0; /* try absolute import on failure */
+ }
+ #endif
+ if (!module) {
+ PyObject *py_level = PyInt_FromLong(level);
+ if (!py_level)
+ goto bad;
+ module = PyObject_CallFunctionObjArgs(py_import,
+ name, global_dict, empty_dict, list, py_level, NULL);
+ Py_DECREF(py_level);
+ }
+ }
+ #else
+ if (level>0) {
+ PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
+ goto bad;
+ }
+ module = PyObject_CallFunctionObjArgs(py_import,
+ name, global_dict, empty_dict, list, NULL);
+ #endif
+bad:
+ Py_XDECREF(empty_list);
+ Py_XDECREF(py_import);
+ Py_XDECREF(empty_dict);
+ return module;
}
static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
PyObject *metaclass;
- /* Default metaclass */
#if PY_MAJOR_VERSION < 3
if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
PyObject *base = PyTuple_GET_ITEM(bases, 0);
@@ -27530,7 +28558,6 @@ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *na
PyObject *metaclass;
if (PyDict_SetItemString(dict, "__module__", modname) < 0)
return NULL;
- /* Python2 __metaclass__ */
metaclass = PyDict_GetItemString(dict, "__metaclass__");
if (metaclass) {
Py_INCREF(metaclass);
@@ -27912,6 +28939,56 @@ __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
PyString_AsString(func_name), (void *)op);
#endif
}
+#if CYTHON_COMPILING_IN_PYPY
+static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
+ PyCFunctionObject* f = (PyCFunctionObject*)func;
+ PyCFunction meth = PyCFunction_GET_FUNCTION(func);
+ PyObject *self = PyCFunction_GET_SELF(func);
+ Py_ssize_t size;
+ switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) {
+ case METH_VARARGS:
+ if (likely(kw == NULL) || PyDict_Size(kw) == 0)
+ return (*meth)(self, arg);
+ break;
+ case METH_VARARGS | METH_KEYWORDS:
+ return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
+ case METH_NOARGS:
+ if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
+ size = PyTuple_GET_SIZE(arg);
+ if (size == 0)
+ return (*meth)(self, NULL);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s() takes no arguments (%zd given)",
+ f->m_ml->ml_name, size);
+ return NULL;
+ }
+ break;
+ case METH_O:
+ if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
+ size = PyTuple_GET_SIZE(arg);
+ if (size == 1)
+ return (*meth)(self, PyTuple_GET_ITEM(arg, 0));
+ PyErr_Format(PyExc_TypeError,
+ "%.200s() takes exactly one argument (%zd given)",
+ f->m_ml->ml_name, size);
+ return NULL;
+ }
+ break;
+ default:
+ PyErr_SetString(PyExc_SystemError, "Bad call flags in "
+ "__Pyx_CyFunction_Call. METH_OLDARGS is no "
+ "longer supported!");
+ return NULL;
+ }
+ PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
+ f->m_ml->ml_name);
+ return NULL;
+}
+#else
+static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
+ return PyCFunction_Call(func, arg, kw);
+}
+#endif
static PyTypeObject __pyx_CyFunctionType_type = {
PyVarObject_HEAD_INIT(0, 0)
__Pyx_NAMESTR("cython_function_or_method"), /*tp_name*/
@@ -27931,7 +29008,7 @@ static PyTypeObject __pyx_CyFunctionType_type = {
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
- __Pyx_PyCFunction_Call, /*tp_call*/
+ __Pyx_CyFunction_Call, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
@@ -27967,15 +29044,16 @@ static PyTypeObject __pyx_CyFunctionType_type = {
0, /*tp_version_tag*/
#endif
};
-static int __Pyx_CyFunction_init(void)
-{
+static int __Pyx_CyFunction_init(void) {
+#if !CYTHON_COMPILING_IN_PYPY
+ __pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
+#endif
if (PyType_Ready(&__pyx_CyFunctionType_type) < 0)
return -1;
__pyx_CyFunctionType = &__pyx_CyFunctionType_type;
return 0;
}
-void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects)
-{
+static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
m->defaults = PyMem_Malloc(size);
if (!m->defaults)
@@ -27984,14 +29062,16 @@ void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects)
m->defaults_pyobjects = pyobjects;
return m->defaults;
}
-static void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple)
-{
+static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
m->defaults_tuple = tuple;
Py_INCREF(tuple);
}
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
+#if CYTHON_COMPILING_IN_PYPY
+ return PyObject_RichCompareBool(s1, s2, equals);
+#else
if (s1 == s2) {
return (equals == Py_EQ);
} else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
@@ -28019,9 +29099,13 @@ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int eq
Py_DECREF(py_result);
return result;
}
+#endif
}
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
+#if CYTHON_COMPILING_IN_PYPY
+ return PyObject_RichCompareBool(s1, s2, equals);
+#else
if (s1 == s2) {
return (equals == Py_EQ);
} else if (PyUnicode_CheckExact(s1) & PyUnicode_CheckExact(s2)) {
@@ -28061,6 +29145,7 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int
Py_DECREF(py_result);
return result;
}
+#endif
}
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
@@ -28463,8 +29548,8 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject*
}
}
-static void __Pyx_WriteUnraisable(const char *name, int clineno,
- int lineno, const char *filename) {
+static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
+ CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename) {
PyObject *old_exc, *old_val, *old_tb;
PyObject *ctx;
__Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
@@ -28484,6 +29569,7 @@ static void __Pyx_WriteUnraisable(const char *name, int clineno,
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
PyObject *tmp_type, *tmp_value, *tmp_tb;
+#if CYTHON_COMPILING_IN_CPYTHON
PyThreadState *tstate = PyThreadState_GET();
tmp_type = tstate->exc_type;
tmp_value = tstate->exc_value;
@@ -28491,6 +29577,10 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value,
tstate->exc_type = *type;
tstate->exc_value = *value;
tstate->exc_traceback = *tb;
+#else
+ PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
+ PyErr_SetExcInfo(*type, *value, *tb);
+#endif
*type = tmp_type;
*value = tmp_value;
*tb = tmp_tb;
@@ -28500,9 +29590,70 @@ static PyObject *__Pyx_Generator_Next(PyObject *self);
static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value);
static PyObject *__Pyx_Generator_Close(PyObject *self);
static PyObject *__Pyx_Generator_Throw(PyObject *gen, PyObject *args);
+static PyTypeObject *__pyx_GeneratorType = 0;
+#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
+#define __Pyx_Generator_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
+#if 1 || PY_VERSION_HEX < 0x030300B0
+static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) {
+ PyObject *et, *ev, *tb;
+ PyObject *value = NULL;
+ __Pyx_ErrFetch(&et, &ev, &tb);
+ if (!et) {
+ Py_XDECREF(tb);
+ Py_XDECREF(ev);
+ Py_INCREF(Py_None);
+ *pvalue = Py_None;
+ return 0;
+ }
+ if (unlikely(et != PyExc_StopIteration) &&
+ unlikely(!PyErr_GivenExceptionMatches(et, PyExc_StopIteration))) {
+ __Pyx_ErrRestore(et, ev, tb);
+ return -1;
+ }
+ if (likely(et == PyExc_StopIteration)) {
+ if (likely(!ev) || !PyObject_IsInstance(ev, PyExc_StopIteration)) {
+ if (!ev) {
+ Py_INCREF(Py_None);
+ ev = Py_None;
+ }
+ Py_XDECREF(tb);
+ Py_DECREF(et);
+ *pvalue = ev;
+ return 0;
+ }
+ }
+ PyErr_NormalizeException(&et, &ev, &tb);
+ if (unlikely(!PyObject_IsInstance(ev, PyExc_StopIteration))) {
+ __Pyx_ErrRestore(et, ev, tb);
+ return -1;
+ }
+ Py_XDECREF(tb);
+ Py_DECREF(et);
+#if PY_VERSION_HEX >= 0x030300A0
+ value = ((PyStopIterationObject *)ev)->value;
+ Py_INCREF(value);
+ Py_DECREF(ev);
+#else
+ {
+ PyObject* args = PyObject_GetAttrString(ev, "args");
+ Py_DECREF(ev);
+ if (likely(args)) {
+ value = PyObject_GetItem(args, 0);
+ Py_DECREF(args);
+ }
+ if (unlikely(!value)) {
+ __Pyx_ErrRestore(NULL, NULL, NULL);
+ Py_INCREF(Py_None);
+ value = Py_None;
+ }
+ }
+#endif
+ *pvalue = value;
+ return 0;
+}
+#endif
static CYTHON_INLINE
-void __Pyx_Generator_ExceptionClear(__pyx_GeneratorObject *self)
-{
+void __Pyx_Generator_ExceptionClear(__pyx_GeneratorObject *self) {
PyObject *exc_type = self->exc_type;
PyObject *exc_value = self->exc_value;
PyObject *exc_traceback = self->exc_traceback;
@@ -28514,14 +29665,18 @@ void __Pyx_Generator_ExceptionClear(__pyx_GeneratorObject *self)
Py_XDECREF(exc_traceback);
}
static CYTHON_INLINE
-PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value)
-{
- PyObject *retval;
- if (unlikely(self->is_running)) {
+int __Pyx_Generator_CheckRunning(__pyx_GeneratorObject *gen) {
+ if (unlikely(gen->is_running)) {
PyErr_SetString(PyExc_ValueError,
"generator already executing");
- return NULL;
+ return 1;
}
+ return 0;
+}
+static CYTHON_INLINE
+PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value) {
+ PyObject *retval;
+ assert(!self->is_running);
if (unlikely(self->resume_label == 0)) {
if (unlikely(value && value != Py_None)) {
PyErr_SetString(PyExc_TypeError,
@@ -28534,81 +29689,240 @@ PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value)
PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
- if (value)
- __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, &self->exc_traceback);
- else
+ if (value) {
+#if CYTHON_COMPILING_IN_PYPY
+#else
+ /* Generators always return to their most recent caller, not
+ * necessarily their creator. */
+ if (self->exc_traceback) {
+ PyThreadState *tstate = PyThreadState_GET();
+ PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
+ PyFrameObject *f = tb->tb_frame;
+ Py_XINCREF(tstate->frame);
+ assert(f->f_back == NULL);
+ f->f_back = tstate->frame;
+ }
+#endif
+ __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
+ &self->exc_traceback);
+ } else {
__Pyx_Generator_ExceptionClear(self);
+ }
self->is_running = 1;
retval = self->body((PyObject *) self, value);
self->is_running = 0;
- if (retval)
- __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, &self->exc_traceback);
- else
+ if (retval) {
+ __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
+ &self->exc_traceback);
+#if CYTHON_COMPILING_IN_PYPY
+#else
+ /* Don't keep the reference to f_back any longer than necessary. It
+ * may keep a chain of frames alive or it could create a reference
+ * cycle. */
+ if (self->exc_traceback) {
+ PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
+ PyFrameObject *f = tb->tb_frame;
+ Py_CLEAR(f->f_back);
+ }
+#endif
+ } else {
__Pyx_Generator_ExceptionClear(self);
+ }
return retval;
}
-static PyObject *__Pyx_Generator_Next(PyObject *self)
-{
- return __Pyx_Generator_SendEx((__pyx_GeneratorObject *) self, Py_None);
+static CYTHON_INLINE
+PyObject *__Pyx_Generator_FinishDelegation(__pyx_GeneratorObject *gen) {
+ PyObject *ret;
+ PyObject *val = NULL;
+ __Pyx_Generator_Undelegate(gen);
+ __Pyx_PyGen_FetchStopIterationValue(&val);
+ ret = __Pyx_Generator_SendEx(gen, val);
+ Py_XDECREF(val);
+ return ret;
+}
+static PyObject *__Pyx_Generator_Next(PyObject *self) {
+ __pyx_GeneratorObject *gen = (__pyx_GeneratorObject*) self;
+ PyObject *yf = gen->yieldfrom;
+ if (unlikely(__Pyx_Generator_CheckRunning(gen)))
+ return NULL;
+ if (yf) {
+ PyObject *ret;
+ gen->is_running = 1;
+ ret = Py_TYPE(yf)->tp_iternext(yf);
+ gen->is_running = 0;
+ if (likely(ret)) {
+ return ret;
+ }
+ return __Pyx_Generator_FinishDelegation(gen);
+ }
+ return __Pyx_Generator_SendEx(gen, Py_None);
}
-static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value)
-{
- return __Pyx_Generator_SendEx((__pyx_GeneratorObject *) self, value);
+static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value) {
+ __pyx_GeneratorObject *gen = (__pyx_GeneratorObject*) self;
+ PyObject *yf = gen->yieldfrom;
+ if (unlikely(__Pyx_Generator_CheckRunning(gen)))
+ return NULL;
+ if (yf) {
+ PyObject *ret;
+ gen->is_running = 1;
+ if (__Pyx_Generator_CheckExact(yf)) {
+ ret = __Pyx_Generator_Send(yf, value);
+ } else {
+ if (value == Py_None)
+ ret = PyIter_Next(yf);
+ else
+ ret = PyObject_CallMethod(yf, (char*)"send", (char*)"O", value);
+ }
+ gen->is_running = 0;
+ if (likely(ret)) {
+ return ret;
+ }
+ return __Pyx_Generator_FinishDelegation(gen);
+ }
+ return __Pyx_Generator_SendEx(gen, value);
+}
+static int __Pyx_Generator_CloseIter(__pyx_GeneratorObject *gen, PyObject *yf) {
+ PyObject *retval = NULL;
+ int err = 0;
+ if (__Pyx_Generator_CheckExact(yf)) {
+ retval = __Pyx_Generator_Close(yf);
+ if (!retval)
+ return -1;
+ } else {
+ PyObject *meth;
+ gen->is_running = 1;
+ meth = PyObject_GetAttrString(yf, "close");
+ if (unlikely(!meth)) {
+ if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_WriteUnraisable(yf);
+ }
+ PyErr_Clear();
+ } else {
+ retval = PyObject_CallFunction(meth, NULL);
+ Py_DECREF(meth);
+ if (!retval)
+ err = -1;
+ }
+ gen->is_running = 0;
+ }
+ Py_XDECREF(retval);
+ return err;
}
-static PyObject *__Pyx_Generator_Close(PyObject *self)
-{
- __pyx_GeneratorObject *generator = (__pyx_GeneratorObject *) self;
- PyObject *retval;
+static PyObject *__Pyx_Generator_Close(PyObject *self) {
+ __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
+ PyObject *retval, *raised_exception;
+ PyObject *yf = gen->yieldfrom;
+ int err = 0;
+ if (unlikely(__Pyx_Generator_CheckRunning(gen)))
+ return NULL;
+ if (yf) {
+ Py_INCREF(yf);
+ err = __Pyx_Generator_CloseIter(gen, yf);
+ __Pyx_Generator_Undelegate(gen);
+ Py_DECREF(yf);
+ }
+ if (err == 0)
#if PY_VERSION_HEX < 0x02050000
- PyErr_SetNone(PyExc_StopIteration);
+ PyErr_SetNone(PyExc_StopIteration);
#else
- PyErr_SetNone(PyExc_GeneratorExit);
+ PyErr_SetNone(PyExc_GeneratorExit);
#endif
- retval = __Pyx_Generator_SendEx(generator, NULL);
+ retval = __Pyx_Generator_SendEx(gen, NULL);
if (retval) {
Py_DECREF(retval);
PyErr_SetString(PyExc_RuntimeError,
"generator ignored GeneratorExit");
return NULL;
}
-#if PY_VERSION_HEX < 0x02050000
- if (PyErr_ExceptionMatches(PyExc_StopIteration))
-#else
- if (PyErr_ExceptionMatches(PyExc_StopIteration)
- || PyErr_ExceptionMatches(PyExc_GeneratorExit))
+ raised_exception = PyErr_Occurred();
+ if (!raised_exception
+ || raised_exception == PyExc_StopIteration
+#if PY_VERSION_HEX >= 0x02050000
+ || raised_exception == PyExc_GeneratorExit
+ || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit)
#endif
+ || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration))
{
- PyErr_Clear(); /* ignore these errors */
+ if (raised_exception) PyErr_Clear(); /* ignore these errors */
Py_INCREF(Py_None);
return Py_None;
}
return NULL;
}
-static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args)
-{
- __pyx_GeneratorObject *generator = (__pyx_GeneratorObject *) self;
+static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) {
+ __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
PyObject *typ;
PyObject *tb = NULL;
PyObject *val = NULL;
+ PyObject *yf = gen->yieldfrom;
if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
return NULL;
+ if (unlikely(__Pyx_Generator_CheckRunning(gen)))
+ return NULL;
+ if (yf) {
+ PyObject *ret;
+ Py_INCREF(yf);
+#if PY_VERSION_HEX >= 0x02050000
+ if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) {
+ int err = __Pyx_Generator_CloseIter(gen, yf);
+ Py_DECREF(yf);
+ __Pyx_Generator_Undelegate(gen);
+ if (err < 0)
+ return __Pyx_Generator_SendEx(gen, NULL);
+ goto throw_here;
+ }
+#endif
+ gen->is_running = 1;
+ if (__Pyx_Generator_CheckExact(yf)) {
+ ret = __Pyx_Generator_Throw(yf, args);
+ } else {
+ PyObject *meth = PyObject_GetAttrString(yf, "throw");
+ if (unlikely(!meth)) {
+ Py_DECREF(yf);
+ if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ gen->is_running = 0;
+ return NULL;
+ }
+ PyErr_Clear();
+ __Pyx_Generator_Undelegate(gen);
+ gen->is_running = 0;
+ goto throw_here;
+ }
+ ret = PyObject_CallObject(meth, args);
+ Py_DECREF(meth);
+ }
+ gen->is_running = 0;
+ Py_DECREF(yf);
+ if (!ret) {
+ ret = __Pyx_Generator_FinishDelegation(gen);
+ }
+ return ret;
+ }
+throw_here:
__Pyx_Raise(typ, val, tb, NULL);
- return __Pyx_Generator_SendEx(generator, NULL);
+ return __Pyx_Generator_SendEx(gen, NULL);
}
-static int
-__Pyx_Generator_traverse(PyObject *self, visitproc visit, void *arg)
-{
+static int __Pyx_Generator_traverse(PyObject *self, visitproc visit, void *arg) {
__pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
Py_VISIT(gen->closure);
Py_VISIT(gen->classobj);
+ Py_VISIT(gen->yieldfrom);
Py_VISIT(gen->exc_type);
Py_VISIT(gen->exc_value);
Py_VISIT(gen->exc_traceback);
return 0;
}
-static void
-__Pyx_Generator_dealloc(PyObject *self)
-{
+static int __Pyx_Generator_clear(PyObject *self) {
+ __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
+ Py_CLEAR(gen->closure);
+ Py_CLEAR(gen->classobj);
+ Py_CLEAR(gen->yieldfrom);
+ Py_CLEAR(gen->exc_type);
+ Py_CLEAR(gen->exc_value);
+ Py_CLEAR(gen->exc_traceback);
+ return 0;
+}
+static void __Pyx_Generator_dealloc(PyObject *self) {
__pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
PyObject_GC_UnTrack(gen);
if (gen->gi_weakreflist != NULL)
@@ -28620,16 +29934,10 @@ __Pyx_Generator_dealloc(PyObject *self)
return; /* resurrected. :( */
}
PyObject_GC_UnTrack(self);
- Py_CLEAR(gen->closure);
- Py_CLEAR(gen->classobj);
- Py_CLEAR(gen->exc_type);
- Py_CLEAR(gen->exc_value);
- Py_CLEAR(gen->exc_traceback);
+ __Pyx_Generator_clear(self);
PyObject_GC_Del(gen);
}
-static void
-__Pyx_Generator_del(PyObject *self)
-{
+static void __Pyx_Generator_del(PyObject *self) {
PyObject *res;
PyObject *error_type, *error_value, *error_traceback;
__pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
@@ -28658,11 +29966,13 @@ __Pyx_Generator_del(PyObject *self)
_Py_NewReference(self);
self->ob_refcnt = refcnt;
}
+#if CYTHON_COMPILING_FOR_CPYTHON
assert(PyType_IS_GC(self->ob_type) &&
_Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
/* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
* we need to undo that. */
_Py_DEC_REFTOTAL;
+#endif
/* If Py_TRACE_REFS, _Py_NewReference re-added self to the object
* chain, so no more to do there.
* If COUNT_ALLOCS, the original decref bumped tp_frees, and
@@ -28670,13 +29980,17 @@ __Pyx_Generator_del(PyObject *self)
* undone.
*/
#ifdef COUNT_ALLOCS
- --self->ob_type->tp_frees;
- --self->ob_type->tp_allocs;
+ --Py_TYPE(self)->tp_frees;
+ --Py_TYPE(self)->tp_allocs;
#endif
}
static PyMemberDef __pyx_Generator_memberlist[] = {
{(char *) "gi_running",
+#if PY_VERSION_HEX >= 0x02060000
+ T_BOOL,
+#else
T_INT,
+#endif
offsetof(__pyx_GeneratorObject, is_running),
READONLY,
NULL},
@@ -28688,7 +30002,7 @@ static PyMethodDef __pyx_Generator_methods[] = {
{__Pyx_NAMESTR("close"), (PyCFunction) __Pyx_Generator_Close, METH_NOARGS, 0},
{0, 0, 0, 0}
};
-static PyTypeObject __pyx_GeneratorType = {
+static PyTypeObject __pyx_GeneratorType_type = {
PyVarObject_HEAD_INIT(0, 0)
__Pyx_NAMESTR("generator"), /*tp_name*/
sizeof(__pyx_GeneratorObject), /*tp_basicsize*/
@@ -28709,7 +30023,7 @@ static PyTypeObject __pyx_GeneratorType = {
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
- PyObject_GenericGetAttr, /*tp_getattro*/
+ 0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/
@@ -28718,7 +30032,7 @@ static PyTypeObject __pyx_GeneratorType = {
0, /*tp_clear*/
0, /*tp_richcompare*/
offsetof(__pyx_GeneratorObject, gi_weakreflist), /* tp_weaklistoffse */
- PyObject_SelfIter, /*tp_iter*/
+ 0, /*tp_iter*/
(iternextfunc) __Pyx_Generator_Next, /*tp_iternext*/
__pyx_Generator_methods, /*tp_methods*/
__pyx_Generator_memberlist, /*tp_members*/
@@ -28743,12 +30057,10 @@ static PyTypeObject __pyx_GeneratorType = {
0, /*tp_version_tag*/
#endif
};
-static
-__pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
- PyObject *closure)
-{
+static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
+ PyObject *closure) {
__pyx_GeneratorObject *gen =
- PyObject_GC_New(__pyx_GeneratorObject, &__pyx_GeneratorType);
+ PyObject_GC_New(__pyx_GeneratorObject, &__pyx_GeneratorType_type);
if (gen == NULL)
return NULL;
gen->body = body;
@@ -28757,6 +30069,7 @@ __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
gen->is_running = 0;
gen->resume_label = 0;
gen->classobj = NULL;
+ gen->yieldfrom = NULL;
gen->exc_type = NULL;
gen->exc_value = NULL;
gen->exc_traceback = NULL;
@@ -28764,9 +30077,14 @@ __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
PyObject_GC_Track(gen);
return gen;
}
-static int __pyx_Generator_init(void)
-{
- return PyType_Ready(&__pyx_GeneratorType);
+static int __pyx_Generator_init(void) {
+ __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr;
+ __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
+ if (PyType_Ready(&__pyx_GeneratorType_type)) {
+ return -1;
+ }
+ __pyx_GeneratorType = &__pyx_GeneratorType_type;
+ return 0;
}
static int __Pyx_check_binary_version(void) {
@@ -28805,6 +30123,147 @@ bad:
return -1;
}
+#ifndef __PYX_HAVE_RT_ImportType
+#define __PYX_HAVE_RT_ImportType
+static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
+ size_t size, int strict)
+{
+ PyObject *py_module = 0;
+ PyObject *result = 0;
+ PyObject *py_name = 0;
+ char warning[200];
+ py_module = __Pyx_ImportModule(module_name);
+ if (!py_module)
+ goto bad;
+ py_name = __Pyx_PyIdentifier_FromString(class_name);
+ if (!py_name)
+ goto bad;
+ result = PyObject_GetAttr(py_module, py_name);
+ Py_DECREF(py_name);
+ py_name = 0;
+ Py_DECREF(py_module);
+ py_module = 0;
+ if (!result)
+ goto bad;
+ if (!PyType_Check(result)) {
+ PyErr_Format(PyExc_TypeError,
+ "%s.%s is not a type object",
+ module_name, class_name);
+ goto bad;
+ }
+ if (!strict && (size_t)((PyTypeObject *)result)->tp_basicsize > size) {
+ PyOS_snprintf(warning, sizeof(warning),
+ "%s.%s size changed, may indicate binary incompatibility",
+ module_name, class_name);
+ #if PY_VERSION_HEX < 0x02050000
+ if (PyErr_Warn(NULL, warning) < 0) goto bad;
+ #else
+ if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
+ #endif
+ }
+ else if ((size_t)((PyTypeObject *)result)->tp_basicsize != size) {
+ PyErr_Format(PyExc_ValueError,
+ "%s.%s has the wrong size, try recompiling",
+ module_name, class_name);
+ goto bad;
+ }
+ return (PyTypeObject *)result;
+bad:
+ Py_XDECREF(py_module);
+ Py_XDECREF(result);
+ return NULL;
+}
+#endif
+
+#ifndef __PYX_HAVE_RT_ImportModule
+#define __PYX_HAVE_RT_ImportModule
+static PyObject *__Pyx_ImportModule(const char *name) {
+ PyObject *py_name = 0;
+ PyObject *py_module = 0;
+ py_name = __Pyx_PyIdentifier_FromString(name);
+ if (!py_name)
+ goto bad;
+ py_module = PyImport_Import(py_name);
+ Py_DECREF(py_name);
+ return py_module;
+bad:
+ Py_XDECREF(py_name);
+ return 0;
+}
+#endif
+
+static void* __Pyx_GetVtable(PyObject *dict) {
+ void* ptr;
+ PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
+ if (!ob)
+ goto bad;
+#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
+ ptr = PyCapsule_GetPointer(ob, 0);
+#else
+ ptr = PyCObject_AsVoidPtr(ob);
+#endif
+ if (!ptr && !PyErr_Occurred())
+ PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
+ Py_DECREF(ob);
+ return ptr;
+bad:
+ Py_XDECREF(ob);
+ return NULL;
+}
+
+#ifndef __PYX_HAVE_RT_ImportFunction
+#define __PYX_HAVE_RT_ImportFunction
+static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
+ PyObject *d = 0;
+ PyObject *cobj = 0;
+ union {
+ void (*fp)(void);
+ void *p;
+ } tmp;
+ d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
+ if (!d)
+ goto bad;
+ cobj = PyDict_GetItemString(d, funcname);
+ if (!cobj) {
+ PyErr_Format(PyExc_ImportError,
+ "%s does not export expected C function %s",
+ PyModule_GetName(module), funcname);
+ goto bad;
+ }
+#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
+ if (!PyCapsule_IsValid(cobj, sig)) {
+ PyErr_Format(PyExc_TypeError,
+ "C function %s.%s has wrong signature (expected %s, got %s)",
+ PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
+ goto bad;
+ }
+ tmp.p = PyCapsule_GetPointer(cobj, sig);
+#else
+ {const char *desc, *s1, *s2;
+ desc = (const char *)PyCObject_GetDesc(cobj);
+ if (!desc)
+ goto bad;
+ s1 = desc; s2 = sig;
+ while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
+ if (*s1 != *s2) {
+ PyErr_Format(PyExc_TypeError,
+ "C function %s.%s has wrong signature (expected %s, got %s)",
+ PyModule_GetName(module), funcname, sig, desc);
+ goto bad;
+ }
+ tmp.p = PyCObject_AsVoidPtr(cobj);}
+#endif
+ *f = tmp.fp;
+ if (!(*f))
+ goto bad;
+ Py_DECREF(d);
+ return 0;
+bad:
+ Py_XDECREF(d);
+ return -1;
+}
+#endif
+
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
int start = 0, mid = 0, end = count - 1;
if (end >= 0 && code_line > entries[end].code_line) {