diff options
Diffstat (limited to 'python/src/_cdec.cpp')
-rw-r--r-- | python/src/_cdec.cpp | 8099 |
1 files changed, 4610 insertions, 3489 deletions
diff --git a/python/src/_cdec.cpp b/python/src/_cdec.cpp index dcd33448..c8d50a4f 100644 --- a/python/src/_cdec.cpp +++ b/python/src/_cdec.cpp @@ -1,4 +1,4 @@ -/* Generated by Cython 0.17.beta1 on Sun Jul 29 23:00:27 2012 */ +/* Generated by Cython 0.17.1 on Tue Oct 16 01:04:11 2012 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -11,7 +11,6 @@ #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif - #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall @@ -23,22 +22,18 @@ #define __fastcall #endif #endif - #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif - #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif - #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif - #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 @@ -46,12 +41,12 @@ #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif - #if PY_VERSION_HEX < 0x02050000 typedef int Py_ssize_t; #define PY_SSIZE_T_MAX INT_MAX #define PY_SSIZE_T_MIN INT_MIN #define PY_FORMAT_SIZE_T "" + #define CYTHON_FORMAT_SSIZE_T "" #define PyInt_FromSsize_t(z) PyInt_FromLong(z) #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \ @@ -63,8 +58,8 @@ #define __PYX_BUILD_PY_SSIZE_T "i" #else #define __PYX_BUILD_PY_SSIZE_T "n" + #define CYTHON_FORMAT_SSIZE_T "z" #endif - #if PY_VERSION_HEX < 0x02060000 #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) @@ -72,7 +67,6 @@ #define PyVarObject_HEAD_INIT(type, size) \ PyObject_HEAD_INIT(type) size, #define PyType_Modified(t) - typedef struct { void *buf; PyObject *obj; @@ -86,7 +80,6 @@ Py_ssize_t *suboffsets; void *internal; } Py_buffer; - #define PyBUF_SIMPLE 0 #define PyBUF_WRITABLE 0x0001 #define PyBUF_FORMAT 0x0004 @@ -98,11 +91,9 @@ #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE) #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE) - typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); typedef void (*releasebufferproc)(PyObject *, Py_buffer *); #endif - #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ @@ -112,21 +103,16 @@ #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #endif - #if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6 #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") #endif - #if PY_MAJOR_VERSION >= 3 #define Py_TPFLAGS_CHECKTYPES 0 #define Py_TPFLAGS_HAVE_INDEX 0 #endif - #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif - - #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ @@ -139,10 +125,8 @@ #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 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject @@ -150,7 +134,6 @@ #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #endif - #if PY_VERSION_HEX < 0x02060000 #define PyBytesObject PyStringObject #define PyBytes_Type PyString_Type @@ -169,7 +152,6 @@ #define PyBytes_Concat PyString_Concat #define PyBytes_ConcatAndDel PyString_ConcatAndDel #endif - #if PY_VERSION_HEX < 0x02060000 #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type) @@ -177,9 +159,7 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif - #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) - #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type @@ -196,11 +176,9 @@ #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #endif - #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif - #if PY_VERSION_HEX < 0x03020000 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong @@ -209,7 +187,6 @@ #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif - #if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300) #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value) @@ -228,11 +205,9 @@ (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \ (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1))) #endif - #if PY_MAJOR_VERSION >= 3 #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) #endif - #if PY_VERSION_HEX < 0x02050000 #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a)) @@ -242,7 +217,6 @@ #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) #endif - #if PY_VERSION_HEX < 0x02050000 #define __Pyx_NAMESTR(n) ((char *)(n)) #define __Pyx_DOCSTR(n) ((char *)(n)) @@ -251,6 +225,7 @@ #define __Pyx_DOCSTR(n) (n) #endif + #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) @@ -275,6 +250,10 @@ #define __PYX_HAVE_API___cdec #include "string.h" #include <string> +#include "ios" +#include "new" +#include "stdexcept" +#include "typeinfo" #include <vector> #include <utility> #include <iostream> @@ -303,6 +282,7 @@ #include "decoder/ff_register.h" #include "decoder/decoder.h" #include "observer.h" +#include "stdio.h" #include "decoder/kbest.h" #include "mteval/ns.h" #include "py_scorer.h" @@ -404,14 +384,17 @@ static const char *__pyx_f[] = { }; /*--- Type declarations ---*/ -struct __pyx_obj_5_cdec_Scorer; +struct __pyx_obj_4cdec_2sa_3_sa_FeatureVector; +struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__; 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_5_cdec_Scorer; +struct __pyx_obj_4cdec_2sa_3_sa_IntList; struct __pyx_obj_4cdec_2sa_3_sa_Phrase; +struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__; struct __pyx_obj_5_cdec_Grammar; +struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines; +struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees; 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__; @@ -419,18 +402,21 @@ struct __pyx_obj_5_cdec_TRule; struct __pyx_obj_4cdec_2sa_3_sa_Rule; struct __pyx_obj_5_cdec_MRule; struct __pyx_obj_5_cdec_SegmentEvaluator; -struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__; +struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr; +struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot; struct __pyx_obj_5_cdec_Candidate; struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr; struct __pyx_obj_5_cdec_NT; +struct __pyx_obj_4cdec_2sa_3_sa_FloatList; struct __pyx_obj_5_cdec_HypergraphEdge; struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__; struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__; struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__; +struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__; 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_17___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; @@ -446,16 +432,14 @@ 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_12___get__; -struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config; +struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config; struct __pyx_obj_5_cdec_TextGrammar; -struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines; struct __pyx_opt_args_5_cdec_as_str; /* "_cdec.pyx":6 * cimport decoder * - * cdef char* as_str(data, char* error_msg='Cannot convert type %s to str'): # <<<<<<<<<<<<<< + * cdef bytes as_str(data, char* error_msg='Cannot convert type %s to str'): # <<<<<<<<<<<<<< * cdef bytes ret * if isinstance(data, unicode): */ @@ -464,21 +448,34 @@ struct __pyx_opt_args_5_cdec_as_str { char *error_msg; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":117 - * return CandidateSet(self) +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":25 + * cdef void read_handle(self, FILE* f) * - * cdef class Scorer: # <<<<<<<<<<<<<< - * cdef string* name - * cdef mteval.EvaluationMetric* metric + * cdef class FeatureVector: # <<<<<<<<<<<<<< + * cdef IntList names + * cdef FloatList values */ -struct __pyx_obj_5_cdec_Scorer { +struct __pyx_obj_4cdec_2sa_3_sa_FeatureVector { PyObject_HEAD - std::string *name; - EvaluationMetric *metric; + struct __pyx_obj_4cdec_2sa_3_sa_IntList *names; + struct __pyx_obj_4cdec_2sa_3_sa_FloatList *values; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":20 +/* "_cdec.pyx":47 + * cdef DenseVector weights + * + * def __init__(self, config_str=None, **config): # <<<<<<<<<<<<<< + * """Decoder('formalism = scfg') -> initialize from configuration string + * Decoder(formalism='scfg') -> initialize from named parameters + */ +struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ { + PyObject_HEAD + PyObject *__pyx_v_config; +}; + + +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":21 * return '[%s]' % self.cat * * cdef class NTRef: # <<<<<<<<<<<<<< @@ -491,37 +488,40 @@ struct __pyx_obj_5_cdec_NTRef { }; -/* "_cdec.pyx":43 - * cdef DenseVector weights +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":121 + * return CandidateSet(self) * - * def __cinit__(self, config_str=None, **config): # <<<<<<<<<<<<<< - * """ Configuration can be given as a string: - * Decoder('formalism = scfg') + * cdef class Scorer: # <<<<<<<<<<<<<< + * cdef string* name + * cdef mteval.EvaluationMetric* metric */ -struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ { +struct __pyx_obj_5_cdec_Scorer { PyObject_HEAD - PyObject *__pyx_v_config; + std::string *name; + EvaluationMetric *metric; }; -/* "_cdec.pyx":54 - * 'csplit', 'tagger', 'lexalign'): - * raise InvalidConfig('formalism "%s" unknown' % formalism) - * config_str = '\n'.join('%s = %s' % kv for kv in _make_config(config)) # <<<<<<<<<<<<<< - * cdef istringstream* config_stream = new istringstream(config_str) - * self.dec = new decoder.Decoder(config_stream) +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":12 + * cdef void read_handle(self, FILE* f) + * + * cdef class IntList: # <<<<<<<<<<<<<< + * cdef int size + * cdef int increment */ -struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr { +struct __pyx_obj_4cdec_2sa_3_sa_IntList { PyObject_HEAD - struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *__pyx_outer_scope; - PyObject *__pyx_v_kv; - PyObject *__pyx_t_0; - Py_ssize_t __pyx_t_1; - PyObject *(*__pyx_t_2)(PyObject *); + struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList *__pyx_vtab; + int size; + int increment; + int len; + int *arr; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":1 +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":29 + * cdef FloatList values + * * cdef class Phrase: # <<<<<<<<<<<<<< * cdef int *syms * cdef int n, *varpos, n_vars @@ -536,8 +536,24 @@ struct __pyx_obj_4cdec_2sa_3_sa_Phrase { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":181 - * super(MRule, self).__init__(lhs, rhs, e, scores, a) +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":90 + * return candidate + * + * def __iter__(self): # <<<<<<<<<<<<<< + * cdef unsigned i + * for i in range(len(self)): + */ +struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ { + PyObject_HEAD + unsigned int __pyx_v_i; + struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self; + Py_ssize_t __pyx_t_0; + unsigned int __pyx_t_1; +}; + + +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":193 + * super(MRule, self).__init__(lhs, rhs, e, scores, None) * * cdef class Grammar: # <<<<<<<<<<<<<< * cdef shared_ptr[grammar.Grammar]* grammar @@ -549,36 +565,64 @@ struct __pyx_obj_5_cdec_Grammar { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":119 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":63 + * def todot(self): + * """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" + * def lines(): # <<<<<<<<<<<<<< + * yield 'digraph lattice {' + * yield 'rankdir = LR;' + */ +struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines { + PyObject_HEAD + struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *__pyx_outer_scope; + PyObject *__pyx_v_delta; + PyObject *__pyx_v_i; + PyObject *__pyx_v_label; + PyObject *__pyx_v_weight; + Py_ssize_t __pyx_t_0; + PyObject *__pyx_t_1; + PyObject *(*__pyx_t_2)(PyObject *); + PyObject *__pyx_t_3; + Py_ssize_t __pyx_t_4; + PyObject *(*__pyx_t_5)(PyObject *); +}; + + +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":103 + * del hypos * - * property nodes: - * def __get__(self): # <<<<<<<<<<<<<< - * cdef unsigned i - * for i in range(self.hg.nodes_.size()): + * def sample_trees(self, unsigned n): # <<<<<<<<<<<<<< + * """hg.sample_trees(n) -> Sample of n trees from the hypergraph.""" + * cdef vector[string]* trees = new vector[string]() */ -struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ { +struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees { PyObject_HEAD - unsigned int __pyx_v_i; + unsigned int __pyx_v_k; + unsigned int __pyx_v_n; struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self; + std::vector<std::string> *__pyx_v_trees; size_t __pyx_t_0; unsigned int __pyx_t_1; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":57 - * yield self[i] +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":156 * - * def todot(self): # <<<<<<<<<<<<<< - * def lines(): - * yield 'digraph lattice {' + * property edges: + * def __get__(self): # <<<<<<<<<<<<<< + * cdef unsigned i + * for i in range(self.hg.edges_.size()): */ -struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot { +struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ { PyObject_HEAD - struct __pyx_obj_5_cdec_Lattice *__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; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":5 * import cdec.sa._sa as _sa * * def _phrase(phrase): # <<<<<<<<<<<<<< @@ -591,7 +635,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":65 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":65 * return result * * cdef class CandidateSet: # <<<<<<<<<<<<<< @@ -606,23 +650,23 @@ struct __pyx_obj_5_cdec_CandidateSet { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":167 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":162 * - * property tail_nodes: + * property nodes: * def __get__(self): # <<<<<<<<<<<<<< * cdef unsigned i - * for i in range(self.edge.tail_nodes_.size()): + * for i in range(self.hg.nodes_.size()): */ struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ { PyObject_HEAD unsigned int __pyx_v_i; - struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self; - unsigned int __pyx_t_0; + struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self; + size_t __pyx_t_0; unsigned int __pyx_t_1; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":50 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":49 * return TRule(lhs, f, e, scores, a) * * cdef class TRule: # <<<<<<<<<<<<<< @@ -635,11 +679,11 @@ struct __pyx_obj_5_cdec_TRule { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":7 +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":35 * cdef public int chunklen(self, int k) * * cdef class Rule: # <<<<<<<<<<<<<< - * cdef public int lhs + * cdef int lhs * cdef readonly Phrase f, e */ struct __pyx_obj_4cdec_2sa_3_sa_Rule { @@ -647,25 +691,25 @@ struct __pyx_obj_4cdec_2sa_3_sa_Rule { int lhs; struct __pyx_obj_4cdec_2sa_3_sa_Phrase *f; struct __pyx_obj_4cdec_2sa_3_sa_Phrase *e; - float *cscores; + struct __pyx_obj_4cdec_2sa_3_sa_FeatureVector *scores; int n_scores; PyObject *word_alignments; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":169 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":177 * _phrase(self.f), _phrase(self.e), scores) * * cdef class MRule(TRule): # <<<<<<<<<<<<<< - * def __init__(self, lhs, rhs, scores, a=None): - * cdef unsigned i = 1 + * def __init__(self, lhs, rhs, scores): + * """MRule(lhs, rhs, scores, a=None) -> Monolingual rule. */ struct __pyx_obj_5_cdec_MRule { struct __pyx_obj_5_cdec_TRule __pyx_base; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":98 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":100 * self.cs.AddKBestCandidates(hypergraph.hg[0], k, self.scorer.get()) * * cdef class SegmentEvaluator: # <<<<<<<<<<<<<< @@ -679,24 +723,37 @@ struct __pyx_obj_5_cdec_SegmentEvaluator { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":44 - * return self.stats.size() - * - * def __iter__(self): # <<<<<<<<<<<<<< - * for i in range(len(self)): - * yield self[i] +/* "_cdec.pyx":56 + * 'csplit', 'tagger', 'lexalign'): + * raise InvalidConfig('formalism "%s" unknown' % formalism) + * config_str = '\n'.join('%s = %s' % kv for kv in _make_config(config)) # <<<<<<<<<<<<<< + * cdef istringstream* config_stream = new istringstream(config_str) + * self.dec = new decoder.Decoder(config_stream) */ -struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ { +struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr { PyObject_HEAD - PyObject *__pyx_v_i; - struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self; - Py_ssize_t __pyx_t_0; - PyObject *__pyx_t_1; + struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *__pyx_outer_scope; + PyObject *__pyx_v_kv; + PyObject *__pyx_t_0; + Py_ssize_t __pyx_t_1; PyObject *(*__pyx_t_2)(PyObject *); }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":12 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":61 + * yield self[i] + * + * def todot(self): # <<<<<<<<<<<<<< + * """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" + * def lines(): + */ +struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot { + PyObject_HEAD + struct __pyx_obj_5_cdec_Lattice *__pyx_v_self; +}; + + +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":12 * return stats * * cdef class Candidate: # <<<<<<<<<<<<<< @@ -710,7 +767,7 @@ struct __pyx_obj_5_cdec_Candidate { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":165 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":173 * * def __str__(self): * scores = ' '.join('%s=%s' % feat for feat in self.scores) # <<<<<<<<<<<<<< @@ -727,7 +784,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":8 +/* "/home/vchahune/tools/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: # <<<<<<<<<<<<<< @@ -741,7 +798,24 @@ struct __pyx_obj_5_cdec_NT { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":147 +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":3 + * from libc.stdio cimport FILE + * + * cdef class FloatList: # <<<<<<<<<<<<<< + * cdef int size + * cdef int increment + */ +struct __pyx_obj_4cdec_2sa_3_sa_FloatList { + PyObject_HEAD + struct __pyx_vtabstruct_4cdec_2sa_3_sa_FloatList *__pyx_vtab; + int size; + int increment; + int len; + float *arr; +}; + + +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":191 * return vector * * cdef class HypergraphEdge: # <<<<<<<<<<<<<< @@ -757,7 +831,7 @@ struct __pyx_obj_5_cdec_HypergraphEdge { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":67 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":72 * self.vector.set_value(fid, value) * * def __iter__(self): # <<<<<<<<<<<<<< @@ -774,12 +848,12 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":209 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":247 * - * property out_edges: + * property in_edges: * def __get__(self): # <<<<<<<<<<<<<< * cdef unsigned i - * for i in range(self.node.out_edges_.size()): + * for i in range(self.node.in_edges_.size()): */ struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ { PyObject_HEAD @@ -790,7 +864,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":124 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":131 * * property a: * def __get__(self): # <<<<<<<<<<<<<< @@ -807,8 +881,24 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ { }; -/* "_cdec.pyx":39 - * yield key, bytes(value) +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":56 + * return unicode(str(self), 'utf8') + * + * def __iter__(self): # <<<<<<<<<<<<<< + * cdef unsigned i + * for i in range(len(self)): + */ +struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ { + PyObject_HEAD + unsigned int __pyx_v_i; + struct __pyx_obj_5_cdec_Lattice *__pyx_v_self; + Py_ssize_t __pyx_t_0; + unsigned int __pyx_t_1; +}; + + +/* "_cdec.pyx":43 + * yield key, str(value) * * cdef class Decoder: # <<<<<<<<<<<<<< * cdef decoder.Decoder* dec @@ -821,7 +911,7 @@ struct __pyx_obj_5_cdec_Decoder { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":193 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":237 * raise NotImplemented('comparison not implemented for HypergraphEdge') * * cdef class HypergraphNode: # <<<<<<<<<<<<<< @@ -836,7 +926,7 @@ struct __pyx_obj_5_cdec_HypergraphNode { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":45 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":48 * return sparse * * cdef class SparseVector: # <<<<<<<<<<<<<< @@ -849,23 +939,23 @@ struct __pyx_obj_5_cdec_SparseVector { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":52 - * return hypergraph.AsPLF(self.lattice[0], True).c_str() +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":253 * - * def __iter__(self): # <<<<<<<<<<<<<< - * cdef unsigned i - * for i in range(len(self)): + * property out_edges: + * def __get__(self): # <<<<<<<<<<<<<< + * cdef unsigned i + * for i in range(self.node.out_edges_.size()): */ -struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ { +struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ { PyObject_HEAD unsigned int __pyx_v_i; - struct __pyx_obj_5_cdec_Lattice *__pyx_v_self; - Py_ssize_t __pyx_t_0; + struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_self; + size_t __pyx_t_0; unsigned int __pyx_t_1; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":31 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":32 * self.vector[0][fid] = value * * def __iter__(self): # <<<<<<<<<<<<<< @@ -881,23 +971,24 @@ struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":90 - * return candidate +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":44 + * return self.stats.size() * * def __iter__(self): # <<<<<<<<<<<<<< - * cdef unsigned i * for i in range(len(self)): + * yield self[i] */ struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ { PyObject_HEAD - unsigned int __pyx_v_i; - struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self; + PyObject *__pyx_v_i; + struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self; Py_ssize_t __pyx_t_0; - unsigned int __pyx_t_1; + PyObject *__pyx_t_1; + PyObject *(*__pyx_t_2)(PyObject *); }; -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":3 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":3 * from cython.operator cimport preincrement as pinc * * cdef class DenseVector: # <<<<<<<<<<<<<< @@ -911,7 +1002,7 @@ struct __pyx_obj_5_cdec_DenseVector { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":187 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":199 * del self.grammar * * def __iter__(self): # <<<<<<<<<<<<<< @@ -930,7 +1021,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":173 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":176 * out.fields[i] = ss[i] * * cdef class Metric: # <<<<<<<<<<<<<< @@ -943,7 +1034,7 @@ struct __pyx_obj_5_cdec_Metric { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":26 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":26 * return fmap * * cdef class SufficientStats: # <<<<<<<<<<<<<< @@ -957,12 +1048,12 @@ struct __pyx_obj_5_cdec_SufficientStats { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":31 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":44 * return unicode(hypergraph.JoshuaVisualizationString(self.hg[0]).c_str(), 'utf8') * * def kbest(self, size): # <<<<<<<<<<<<<< + * """hg.kbest(size) -> List of k-best hypotheses in the hypergraph.""" * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal]* derivations = new kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal](self.hg[0], size) - * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal].Derivation* derivation */ struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest { PyObject_HEAD @@ -976,12 +1067,12 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":61 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":76 * del e_derivations * * def kbest_features(self, size): # <<<<<<<<<<<<<< + * """hg.kbest_trees(size) -> List of k-best feature vectors in the hypergraph.""" * cdef kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal]* derivations = new kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal](self.hg[0], size) - * cdef kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal].Derivation* derivation */ struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features { PyObject_HEAD @@ -996,24 +1087,24 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":203 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":211 * - * property in_edges: + * property tail_nodes: * def __get__(self): # <<<<<<<<<<<<<< * cdef unsigned i - * for i in range(self.node.in_edges_.size()): + * for i in range(self.edge.tail_nodes_.size()): */ struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ { PyObject_HEAD unsigned int __pyx_v_i; - struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_self; - size_t __pyx_t_0; + struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self; + unsigned int __pyx_t_0; unsigned int __pyx_t_1; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":164 - * self.rule.get().lhs_ = -TDConvert(<char *>lhs.cat) +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":172 + * self.rule.get().lhs_ = -TDConvert((<NT> lhs).cat) * * def __str__(self): # <<<<<<<<<<<<<< * scores = ' '.join('%s=%s' % feat for feat in self.scores) @@ -1025,7 +1116,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":6 +/* "/home/vchahune/tools/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) # <<<<<<<<<<<<<< @@ -1042,12 +1133,12 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":43 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":57 * del derivations * * def kbest_trees(self, size): # <<<<<<<<<<<<<< + * """hg.kbest_trees(size) -> List of k-best trees in the hypergraph.""" * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal]* f_derivations = new kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal](self.hg[0], size) - * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal].Derivation* f_derivation */ struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees { PyObject_HEAD @@ -1065,7 +1156,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":4 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":4 * cimport kbest * * cdef class Hypergraph: # <<<<<<<<<<<<<< @@ -1074,12 +1165,13 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees { */ struct __pyx_obj_5_cdec_Hypergraph { PyObject_HEAD + struct __pyx_vtabstruct_5_cdec_Hypergraph *__pyx_vtab; Hypergraph *hg; MT19937 *rng; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":3 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":3 * cimport lattice * * cdef class Lattice: # <<<<<<<<<<<<<< @@ -1092,12 +1184,12 @@ struct __pyx_obj_5_cdec_Lattice { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":76 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":92 * del derivations * * def sample(self, unsigned n): # <<<<<<<<<<<<<< + * """hg.sample(n) -> Sample of n hypotheses from the hypergraph.""" * cdef vector[hypergraph.Hypothesis]* hypos = new vector[hypergraph.Hypothesis]() - * if self.rng == NULL: */ struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample { PyObject_HEAD @@ -1110,30 +1202,14 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":113 - * - * property edges: - * def __get__(self): # <<<<<<<<<<<<<< - * cdef unsigned i - * for i in range(self.hg.edges_.size()): - */ -struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ { - PyObject_HEAD - unsigned int __pyx_v_i; - struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self; - size_t __pyx_t_0; - unsigned int __pyx_t_1; -}; - - -/* "_cdec.pyx":28 - * class ParseFailed(Exception): pass +/* "_cdec.pyx":32 + * SetSilent(yn) * * def _make_config(config): # <<<<<<<<<<<<<< * for key, value in config.items(): * if isinstance(value, dict): */ -struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config { +struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config { PyObject_HEAD PyObject *__pyx_v_config; PyObject *__pyx_v_info; @@ -1149,43 +1225,86 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":204 - * self.grammar.get().SetGrammarName(string(<char *>name)) +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":217 + * self.grammar.get().SetGrammarName(name) * * cdef class TextGrammar(Grammar): # <<<<<<<<<<<<<< - * def __cinit__(self, rules): - * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) + * def __init__(self, rules): + * """TextGrammar(rules) -> SCFG Grammar containing the rules.""" */ struct __pyx_obj_5_cdec_TextGrammar { struct __pyx_obj_5_cdec_Grammar __pyx_base; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":58 + +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":4 + * cimport kbest * - * def todot(self): - * def lines(): # <<<<<<<<<<<<<< - * yield 'digraph lattice {' - * yield 'rankdir = LR;' + * cdef class Hypergraph: # <<<<<<<<<<<<<< + * cdef hypergraph.Hypergraph* hg + * cdef MT19937* rng */ -struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines { - PyObject_HEAD - struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *__pyx_outer_scope; - PyObject *__pyx_v_delta; - PyObject *__pyx_v_i; - PyObject *__pyx_v_label; - PyObject *__pyx_v_weight; - Py_ssize_t __pyx_t_0; - PyObject *__pyx_t_1; - PyObject *(*__pyx_t_2)(PyObject *); - PyObject *__pyx_t_3; - Py_ssize_t __pyx_t_4; - PyObject *(*__pyx_t_5)(PyObject *); + +struct __pyx_vtabstruct_5_cdec_Hypergraph { + MT19937 *(*_rng)(struct __pyx_obj_5_cdec_Hypergraph *); }; +static struct __pyx_vtabstruct_5_cdec_Hypergraph *__pyx_vtabptr_5_cdec_Hypergraph; +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":191 + * return vector + * + * cdef class HypergraphEdge: # <<<<<<<<<<<<<< + * cdef hypergraph.Hypergraph* hg + * cdef hypergraph.HypergraphEdge* edge + */ -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":1 +struct __pyx_vtabstruct_5_cdec_HypergraphEdge { + PyObject *(*init)(struct __pyx_obj_5_cdec_HypergraphEdge *, Hypergraph *, unsigned int); +}; +static struct __pyx_vtabstruct_5_cdec_HypergraphEdge *__pyx_vtabptr_5_cdec_HypergraphEdge; + + +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":12 + * cdef void read_handle(self, FILE* f) + * + * cdef class IntList: # <<<<<<<<<<<<<< + * cdef int size + * cdef int increment + */ + +struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList { + void (*set)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, int, int); + void (*_append)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, int); + void (*_extend)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, struct __pyx_obj_4cdec_2sa_3_sa_IntList *); + void (*_extend_arr)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, int *, int); + void (*_clear)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *); + void (*write_handle)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, FILE *); + void (*read_handle)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, FILE *); +}; +static struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList *__pyx_vtabptr_4cdec_2sa_3_sa_IntList; + + +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":3 + * from libc.stdio cimport FILE + * + * cdef class FloatList: # <<<<<<<<<<<<<< + * cdef int size + * cdef int increment + */ + +struct __pyx_vtabstruct_4cdec_2sa_3_sa_FloatList { + void (*set)(struct __pyx_obj_4cdec_2sa_3_sa_FloatList *, int, float); + void (*write_handle)(struct __pyx_obj_4cdec_2sa_3_sa_FloatList *, FILE *); + void (*read_handle)(struct __pyx_obj_4cdec_2sa_3_sa_FloatList *, FILE *); +}; +static struct __pyx_vtabstruct_4cdec_2sa_3_sa_FloatList *__pyx_vtabptr_4cdec_2sa_3_sa_FloatList; + + +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":29 + * cdef FloatList values + * * cdef class Phrase: # <<<<<<<<<<<<<< * cdef int *syms * cdef int n, *varpos, n_vars @@ -1198,7 +1317,7 @@ struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase { 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 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":237 * raise NotImplemented('comparison not implemented for HypergraphEdge') * * cdef class HypergraphNode: # <<<<<<<<<<<<<< @@ -1210,20 +1329,6 @@ struct __pyx_vtabstruct_5_cdec_HypergraphNode { PyObject *(*init)(struct __pyx_obj_5_cdec_HypergraphNode *, Hypergraph *, unsigned int); }; static struct __pyx_vtabstruct_5_cdec_HypergraphNode *__pyx_vtabptr_5_cdec_HypergraphNode; - - -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":147 - * return vector - * - * cdef class HypergraphEdge: # <<<<<<<<<<<<<< - * cdef hypergraph.Hypergraph* hg - * cdef hypergraph.HypergraphEdge* edge - */ - -struct __pyx_vtabstruct_5_cdec_HypergraphEdge { - PyObject *(*init)(struct __pyx_obj_5_cdec_HypergraphEdge *, Hypergraph *, unsigned int); -}; -static struct __pyx_vtabstruct_5_cdec_HypergraphEdge *__pyx_vtabptr_5_cdec_HypergraphEdge; #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif @@ -1308,22 +1413,6 @@ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ const char* function_name); /*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 (unlikely(PyList_Append(L, x) < 0)) return NULL; @@ -1433,11 +1522,9 @@ static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/ -static CYTHON_INLINE int __Pyx_NegateNonNeg(int b) { - return unlikely(b < 0) ? b : !b; -} -static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) { - return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b); +static CYTHON_INLINE int __Pyx_PyDict_Contains(PyObject* item, PyObject* dict, int eq) { + int result = PyDict_Contains(dict, item); + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); } #define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL) @@ -1552,18 +1639,6 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, PyObject *tuple); static int __Pyx_CyFunction_init(void); -#include <string.h> - -static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/ - -static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/ - -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals -#else -#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals -#endif - static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); @@ -1596,9 +1671,6 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); 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); /*proto*/ - static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ #define __Pyx_Generator_USED @@ -1609,14 +1681,14 @@ typedef struct { PyObject_HEAD __pyx_generator_body_t body; PyObject *closure; - int is_running; - int resume_label; PyObject *exc_type; PyObject *exc_value; PyObject *exc_traceback; PyObject *gi_weakreflist; PyObject *classobj; PyObject *yieldfrom; + int resume_label; + char is_running; // using T_BOOL for property below requires char value } __pyx_GeneratorObject; static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body, PyObject *closure); @@ -1628,6 +1700,9 @@ static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue); #define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue) #endif +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename); /*proto*/ + static int __Pyx_check_binary_version(void); static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ @@ -1640,10 +1715,10 @@ static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ #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 PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/ + static void* __Pyx_GetVtable(PyObject *dict); /*proto*/ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/ @@ -1688,7 +1763,12 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ /* Module declarations from 'decoder' */ +/* Module declarations from 'libc.stdio' */ + /* Module declarations from 'cdec.sa._sa' */ +static PyTypeObject *__pyx_ptype_4cdec_2sa_3_sa_FloatList = 0; +static PyTypeObject *__pyx_ptype_4cdec_2sa_3_sa_IntList = 0; +static PyTypeObject *__pyx_ptype_4cdec_2sa_3_sa_FeatureVector = 0; 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*/ @@ -1732,25 +1812,26 @@ static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_8_kbest = 0; static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_9_kbest_trees = 0; static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_10_kbest_features = 0; static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_11_sample = 0; -static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_12___get__ = 0; +static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_12_sample_trees = 0; static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_13___get__ = 0; static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_14___get__ = 0; static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_15___get__ = 0; static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_16___get__ = 0; -static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_17___iter__ = 0; -static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_18_todot = 0; -static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_19_lines = 0; -static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_20___iter__ = 0; +static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_17___get__ = 0; +static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_18___iter__ = 0; +static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_19_todot = 0; +static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_20_lines = 0; static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_21___iter__ = 0; -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 PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_22___iter__ = 0; +static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_23__make_config = 0; +static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_24___init__ = 0; +static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_25_genexpr = 0; +static PyObject *__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*/ +static std::string __pyx_convert_string_from_py_(PyObject *); /*proto*/ #define __Pyx_MODULE_NAME "_cdec" int __pyx_module_is_main__cdec = 0; @@ -1762,6 +1843,7 @@ static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_NotImplemented; static PyObject *__pyx_builtin_super; static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_basestring; static PyObject *__pyx_builtin_eval; static PyObject *__pyx_builtin_enumerate; static PyObject *__pyx_builtin_IndexError; @@ -1799,7 +1881,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_37__div__(PyObject *__pyx_v_x, P #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 */ -static int __pyx_pf_5_cdec_2NT___init__(struct __pyx_obj_5_cdec_NT *__pyx_v_self, char *__pyx_v_cat, unsigned int __pyx_v_ref); /* proto */ +static int __pyx_pf_5_cdec_2NT___init__(struct __pyx_obj_5_cdec_NT *__pyx_v_self, PyObject *__pyx_v_cat, unsigned int __pyx_v_ref); /* proto */ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_2NT_3cat___get__(struct __pyx_obj_5_cdec_NT *__pyx_v_self); /* proto */ static int __pyx_pf_5_cdec_2NT_3cat_2__set__(struct __pyx_obj_5_cdec_NT *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ @@ -1825,12 +1907,12 @@ static PyObject *__pyx_pf_5_cdec_5TRule_3lhs___get__(struct __pyx_obj_5_cdec_TRu static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_lhs); /* proto */ static PyObject *__pyx_pf_5_cdec_5TRule_7__str___genexpr(PyObject *__pyx_self); /* proto */ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */ -static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_rhs, PyObject *__pyx_v_scores, PyObject *__pyx_v_a); /* proto */ +static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_rhs, PyObject *__pyx_v_scores); /* 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 */ static int __pyx_pf_5_cdec_7Grammar_4name_2__set__(struct __pyx_obj_5_cdec_Grammar *__pyx_v_self, PyObject *__pyx_v_name); /* proto */ -static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextGrammar *__pyx_v_self, PyObject *__pyx_v_rules); /* proto */ +static int __pyx_pf_5_cdec_11TextGrammar___init__(struct __pyx_obj_5_cdec_TextGrammar *__pyx_v_self, PyObject *__pyx_v_rules); /* proto */ static void __pyx_pf_5_cdec_10Hypergraph___dealloc__(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ @@ -1840,15 +1922,17 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_10kbest(struct __pyx_obj_5_cdec_Hy static PyObject *__pyx_pf_5_cdec_10Hypergraph_13kbest_trees(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_16kbest_features(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_19sample(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, unsigned int __pyx_v_n); /* proto */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_22intersect(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, struct __pyx_obj_5_cdec_Lattice *__pyx_v_lat); /* proto */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_24prune(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_beam_alpha, PyObject *__pyx_v_density, PyObject *__pyx_v_kwargs); /* proto */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_26lattice(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_28reweight(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_weights); /* proto */ +static PyObject *__pyx_pf_5_cdec_10Hypergraph_22sample_trees(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, unsigned int __pyx_v_n); /* proto */ +static PyObject *__pyx_pf_5_cdec_10Hypergraph_25intersect(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */ +static PyObject *__pyx_pf_5_cdec_10Hypergraph_27prune(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_beam_alpha, PyObject *__pyx_v_density, PyObject *__pyx_v_kwargs); /* proto */ +static PyObject *__pyx_pf_5_cdec_10Hypergraph_29lattice(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_10Hypergraph_31plf(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_10Hypergraph_33reweight(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_weights); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_5edges___get__(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_5nodes___get__(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4goal___get__(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6npaths___get__(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ static Py_ssize_t __pyx_pf_5_cdec_14HypergraphEdge___len__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_9head_node___get__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_10tail_nodes___get__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self); /* proto */ @@ -1864,15 +1948,18 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_9out_edges___get__(struct __py static PyObject *__pyx_pf_5_cdec_14HypergraphNode_4span___get__(struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_self); /* proto */ 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 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 int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ +static int __pyx_pf_5_cdec_7Lattice_2__init__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */ +static void __pyx_pf_5_cdec_7Lattice_4__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_7Lattice_6__getitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index); /* proto */ +static int __pyx_pf_5_cdec_7Lattice_8__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_10__len__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_7Lattice_12__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_7Lattice_14__unicode__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_7Lattice_16__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_7Lattice_19todot(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_7Lattice_21as_hypergraph(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 */ static PyObject *__pyx_pf_5_cdec_9Candidate_4fmap___get__(struct __pyx_obj_5_cdec_Candidate *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_9Candidate_5score___get__(struct __pyx_obj_5_cdec_Candidate *__pyx_v_self); /* proto */ @@ -1902,9 +1989,10 @@ static int __pyx_pf_5_cdec_6Metric___cinit__(struct __pyx_obj_5_cdec_Metric *__p static PyObject *__pyx_pf_5_cdec_6Metric_2__call__(struct __pyx_obj_5_cdec_Metric *__pyx_v_self, PyObject *__pyx_v_refs); /* proto */ static PyObject *__pyx_pf_5_cdec_6Metric_4score(CYTHON_UNUSED struct __pyx_obj_5_cdec_Metric *__pyx_v_stats); /* proto */ static PyObject *__pyx_pf_5_cdec_6Metric_6evaluate(CYTHON_UNUSED struct __pyx_obj_5_cdec_Metric *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_hyp, CYTHON_UNUSED PyObject *__pyx_v_refs); /* proto */ -static PyObject *__pyx_pf_5_cdec_2_make_config(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_config); /* proto */ -static PyObject *__pyx_pf_5_cdec_7Decoder_9__cinit___genexpr(PyObject *__pyx_self); /* proto */ -static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_config_str, PyObject *__pyx_v_config); /* proto */ +static PyObject *__pyx_pf_5_cdec_2set_silent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_yn); /* proto */ +static PyObject *__pyx_pf_5_cdec_4_make_config(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_config); /* proto */ +static PyObject *__pyx_pf_5_cdec_7Decoder_8__init___genexpr(PyObject *__pyx_self); /* proto */ +static int __pyx_pf_5_cdec_7Decoder___init__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_config_str, PyObject *__pyx_v_config); /* proto */ static void __pyx_pf_5_cdec_7Decoder_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Decoder *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_7Decoder_7weights___get__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self); /* proto */ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_weights); /* proto */ @@ -1921,40 +2009,42 @@ static char __pyx_k_10[] = "[%d]"; static char __pyx_k_11[] = "%s=%s"; static char __pyx_k_12[] = "%s ||| %s ||| %s ||| %s"; static char __pyx_k_13[] = "the grammar should contain TRule objects"; -static char __pyx_k_15[] = "csplit_preserve_full_word"; -static char __pyx_k_16[] = "cannot reweight hypergraph with %s"; -static char __pyx_k_17[] = "comparison not implemented for HypergraphEdge"; -static char __pyx_k_19[] = "comparison not implemented for HypergraphNode"; -static char __pyx_k_22[] = "Cannot create lattice from %s"; +static char __pyx_k_15[] = "cannot intersect hypergraph with %s"; +static char __pyx_k_16[] = "csplit_preserve_full_word"; +static char __pyx_k_17[] = "cannot reweight hypergraph with %s"; +static char __pyx_k_18[] = "comparison not implemented for HypergraphEdge"; +static char __pyx_k_20[] = "comparison not implemented for HypergraphNode"; +static char __pyx_k_22[] = "cannot create lattice from %s"; static char __pyx_k_23[] = "lattice index out of range"; -static char __pyx_k_27[] = "digraph lattice {"; - static char __pyx_k_28[] = "rankdir = LR;"; - static char __pyx_k_29[] = "node [shape=circle];"; - static char __pyx_k_30[] = "%d -> %d [label=\"%s\"];"; - static char __pyx_k_31[] = "\""; - static char __pyx_k_32[] = "\\\""; - static char __pyx_k_34[] = "%d [shape=doublecircle]"; -static char __pyx_k_35[] = "}"; -static char __pyx_k_38[] = "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi"; -static char __pyx_k_39[] = "\n"; -static char __pyx_k_41[] = "sufficient stats vector index out of range"; -static char __pyx_k_43[] = "candidate set index out of range"; -static char __pyx_k_45[] = "%s %s"; -static char __pyx_k_46[] = "%s = %s"; -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_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_26[] = "digraph lattice {"; + static char __pyx_k_27[] = "rankdir = LR;"; + static char __pyx_k_28[] = "node [shape=circle];"; + static char __pyx_k_29[] = "%d -> %d [label=\"%s\"];"; + static char __pyx_k_30[] = "\""; + static char __pyx_k_31[] = "\\\""; + static char __pyx_k_33[] = "%d [shape=doublecircle]"; +static char __pyx_k_34[] = "}"; +static char __pyx_k_37[] = "/home/vchahune/tools/cdec/python/src/lattice.pxi"; +static char __pyx_k_38[] = "\n"; +static char __pyx_k_40[] = "sufficient stats vector index out of range"; +static char __pyx_k_42[] = "candidate set index out of range"; +static char __pyx_k_44[] = "%s %s"; +static char __pyx_k_45[] = "%s = %s"; +static char __pyx_k_47[] = "formalism \"%s\" unknown"; +static char __pyx_k_48[] = "cannot initialize weights with %s"; +static char __pyx_k_49[] = "#"; +static char __pyx_k_52[] = "Cannot translate input type %s"; +static char __pyx_k_53[] = "cdec.sa._sa"; +static char __pyx_k_54[] = "*"; +static char __pyx_k_57[] = "/home/vchahune/tools/cdec/python/src/grammar.pxi"; +static char __pyx_k_63[] = "/home/vchahune/tools/cdec/python/src/_cdec.pyx"; static char __pyx_k__a[] = "a"; static char __pyx_k__e[] = "e"; static char __pyx_k__f[] = "f"; static char __pyx_k__i[] = "i"; static char __pyx_k__k[] = "k"; static char __pyx_k__pb[] = "pb"; +static char __pyx_k__yn[] = "yn"; static char __pyx_k__CER[] = "CER"; static char __pyx_k__TER[] = "TER"; static char __pyx_k___sa[] = "_sa"; @@ -2027,12 +2117,14 @@ static char __pyx_k__evaluator[] = "evaluator"; static char __pyx_k__formalism[] = "formalism"; static char __pyx_k__IndexError[] = "IndexError"; static char __pyx_k__ValueError[] = "ValueError"; +static char __pyx_k__alignments[] = "alignments"; +static char __pyx_k__basestring[] = "basestring"; static char __pyx_k__beam_alpha[] = "beam_alpha"; static char __pyx_k__config_str[] = "config_str"; static char __pyx_k__hypergraph[] = "hypergraph"; +static char __pyx_k__set_silent[] = "set_silent"; 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"; @@ -2040,36 +2132,37 @@ static PyObject *__pyx_kp_s_10; static PyObject *__pyx_kp_s_11; static PyObject *__pyx_kp_s_12; static PyObject *__pyx_kp_s_13; -static PyObject *__pyx_n_s_15; -static PyObject *__pyx_kp_s_16; +static PyObject *__pyx_kp_s_15; +static PyObject *__pyx_n_s_16; static PyObject *__pyx_kp_s_17; -static PyObject *__pyx_kp_s_19; +static PyObject *__pyx_kp_s_18; +static PyObject *__pyx_kp_s_20; static PyObject *__pyx_kp_s_22; static PyObject *__pyx_kp_s_23; +static PyObject *__pyx_kp_s_26; static PyObject *__pyx_kp_s_27; static PyObject *__pyx_kp_s_28; static PyObject *__pyx_kp_s_29; static PyObject *__pyx_kp_s_3; static PyObject *__pyx_kp_s_30; static PyObject *__pyx_kp_s_31; -static PyObject *__pyx_kp_s_32; +static PyObject *__pyx_kp_s_33; static PyObject *__pyx_kp_s_34; -static PyObject *__pyx_kp_s_35; +static PyObject *__pyx_kp_s_37; static PyObject *__pyx_kp_s_38; -static PyObject *__pyx_kp_s_39; static PyObject *__pyx_kp_s_4; -static PyObject *__pyx_kp_s_41; -static PyObject *__pyx_kp_s_43; +static PyObject *__pyx_kp_s_40; +static PyObject *__pyx_kp_s_42; +static PyObject *__pyx_kp_s_44; static PyObject *__pyx_kp_s_45; -static PyObject *__pyx_kp_s_46; +static PyObject *__pyx_kp_s_47; 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_52; +static PyObject *__pyx_n_s_53; 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_57; +static PyObject *__pyx_kp_s_63; static PyObject *__pyx_kp_s_7; static PyObject *__pyx_kp_s_8; static PyObject *__pyx_kp_s_9; @@ -2082,7 +2175,6 @@ 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; @@ -2098,6 +2190,8 @@ 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__alignments; +static PyObject *__pyx_n_s__basestring; static PyObject *__pyx_n_s__beam_alpha; static PyObject *__pyx_n_s__cat; static PyObject *__pyx_n_s__config; @@ -2151,6 +2245,7 @@ static PyObject *__pyx_n_s__score; static PyObject *__pyx_n_s__scores; static PyObject *__pyx_n_s__self; static PyObject *__pyx_n_s__sentence; +static PyObject *__pyx_n_s__set_silent; static PyObject *__pyx_n_s__span; static PyObject *__pyx_n_s__split; static PyObject *__pyx_n_s__startswith; @@ -2160,54 +2255,53 @@ static PyObject *__pyx_n_s__tagger; static PyObject *__pyx_n_s__utf8; static PyObject *__pyx_n_s__value; static PyObject *__pyx_n_s__weight; +static PyObject *__pyx_n_s__yn; 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; static PyObject *__pyx_k_tuple_14; -static PyObject *__pyx_k_tuple_18; -static PyObject *__pyx_k_tuple_20; +static PyObject *__pyx_k_tuple_19; static PyObject *__pyx_k_tuple_21; static PyObject *__pyx_k_tuple_24; static PyObject *__pyx_k_tuple_25; -static PyObject *__pyx_k_tuple_26; -static PyObject *__pyx_k_tuple_33; -static PyObject *__pyx_k_tuple_36; -static PyObject *__pyx_k_tuple_40; -static PyObject *__pyx_k_tuple_42; -static PyObject *__pyx_k_tuple_44; -static PyObject *__pyx_k_tuple_47; +static PyObject *__pyx_k_tuple_32; +static PyObject *__pyx_k_tuple_35; +static PyObject *__pyx_k_tuple_39; +static PyObject *__pyx_k_tuple_41; +static PyObject *__pyx_k_tuple_43; +static PyObject *__pyx_k_tuple_46; +static PyObject *__pyx_k_tuple_50; static PyObject *__pyx_k_tuple_51; -static PyObject *__pyx_k_tuple_52; -static PyObject *__pyx_k_tuple_56; +static PyObject *__pyx_k_tuple_55; +static PyObject *__pyx_k_tuple_58; 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_57; -static PyObject *__pyx_k_codeobj_63; +static PyObject *__pyx_k_tuple_64; +static PyObject *__pyx_k_codeobj_36; +static PyObject *__pyx_k_codeobj_56; +static PyObject *__pyx_k_codeobj_62; +static PyObject *__pyx_k_codeobj_65; /* "_cdec.pyx":6 * cimport decoder * - * cdef char* as_str(data, char* error_msg='Cannot convert type %s to str'): # <<<<<<<<<<<<<< + * cdef bytes 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) { +static PyObject *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_data, struct __pyx_opt_args_5_cdec_as_str *__pyx_optional_args) { char *__pyx_v_error_msg = ((char *)__pyx_k_1); PyObject *__pyx_v_ret = 0; - char *__pyx_r; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; - char *__pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -2219,7 +2313,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, char* error_msg='Cannot convert type %s to str'): + * cdef bytes as_str(data, char* error_msg='Cannot convert type %s to str'): * cdef bytes ret * if isinstance(data, unicode): # <<<<<<<<<<<<<< * ret = data.encode('utf8') @@ -2318,26 +2412,32 @@ static char *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_data, struct __pyx_opt_args * * include "vectors.pxi" */ - __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; + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(((PyObject *)__pyx_v_ret)); + __pyx_r = __pyx_v_ret; goto __pyx_L0; - __pyx_r = 0; + __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0; __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_AddTraceback("_cdec.as_str", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_ret); + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_5_cdec_11DenseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_11DenseVector___init__[] = "DenseVector() -> Dense weight/feature vector."; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_11DenseVector___init__; +#endif static int __pyx_pw_5_cdec_11DenseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations @@ -2350,30 +2450,35 @@ static int __pyx_pw_5_cdec_11DenseVector_1__init__(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":7 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":7 * cdef bint owned # if True, do not manage memory * * def __init__(self): # <<<<<<<<<<<<<< + * """DenseVector() -> Dense weight/feature vector.""" * 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 + std::vector<weight_t> *__pyx_t_1; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":8 - * + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":9 * def __init__(self): + * """DenseVector() -> Dense weight/feature vector.""" * self.vector = new vector[weight_t]() # <<<<<<<<<<<<<< * self.owned = False * */ - __pyx_v_self->vector = new std::vector<weight_t>(); + try {__pyx_t_1 = new std::vector<weight_t>();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_v_self->vector = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":9 - * def __init__(self): + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":10 + * """DenseVector() -> Dense weight/feature vector.""" * self.vector = new vector[weight_t]() * self.owned = False # <<<<<<<<<<<<<< * @@ -2382,6 +2487,11 @@ static int __pyx_pf_5_cdec_11DenseVector___init__(struct __pyx_obj_5_cdec_DenseV __pyx_v_self->owned = 0; __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("_cdec.DenseVector.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -2395,7 +2505,7 @@ static void __pyx_pw_5_cdec_11DenseVector_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":11 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":12 * self.owned = False * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -2408,7 +2518,7 @@ static void __pyx_pf_5_cdec_11DenseVector_2__dealloc__(struct __pyx_obj_5_cdec_D int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":12 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":13 * * def __dealloc__(self): * if not self.owned: # <<<<<<<<<<<<<< @@ -2418,7 +2528,7 @@ static void __pyx_pf_5_cdec_11DenseVector_2__dealloc__(struct __pyx_obj_5_cdec_D __pyx_t_1 = (!__pyx_v_self->owned); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":13 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":14 * def __dealloc__(self): * if not self.owned: * del self.vector # <<<<<<<<<<<<<< @@ -2444,7 +2554,7 @@ static Py_ssize_t __pyx_pw_5_cdec_11DenseVector_5__len__(PyObject *__pyx_v_self) return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":15 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":16 * del self.vector * * def __len__(self): # <<<<<<<<<<<<<< @@ -2457,7 +2567,7 @@ static Py_ssize_t __pyx_pf_5_cdec_11DenseVector_4__len__(struct __pyx_obj_5_cdec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":16 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":17 * * def __len__(self): * return self.vector.size() # <<<<<<<<<<<<<< @@ -2481,7 +2591,7 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_7__getitem__(PyObject *__pyx_v_se __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 = 18; __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 = 19; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2494,7 +2604,7 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_7__getitem__(PyObject *__pyx_v_se return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":18 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":19 * return self.vector.size() * * def __getitem__(self, char* fname): # <<<<<<<<<<<<<< @@ -2514,7 +2624,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_6__getitem__(struct __pyx_obj_5_c int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":19 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":20 * * def __getitem__(self, char* fname): * cdef int fid = FDConvert(fname) # <<<<<<<<<<<<<< @@ -2523,7 +2633,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_6__getitem__(struct __pyx_obj_5_c */ __pyx_v_fid = FD::Convert(__pyx_v_fname); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":20 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":21 * def __getitem__(self, char* fname): * cdef int fid = FDConvert(fname) * if 0 <= fid < self.vector.size(): # <<<<<<<<<<<<<< @@ -2536,7 +2646,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_6__getitem__(struct __pyx_obj_5_c } if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":21 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":22 * cdef int fid = FDConvert(fname) * if 0 <= fid < self.vector.size(): * return self.vector[0][fid] # <<<<<<<<<<<<<< @@ -2544,7 +2654,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_6__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 = 21; __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 = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; @@ -2553,26 +2663,26 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_6__getitem__(struct __pyx_obj_5_c } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":22 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":23 * 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 = 22; __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 = 23; __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 = 22; __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 = 23; __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 = 22; __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 = 23; __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 = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; @@ -2596,10 +2706,10 @@ static int __pyx_pw_5_cdec_11DenseVector_9__setitem__(PyObject *__pyx_v_self, Py __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 = 24; __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 = 25; __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 = 24; __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 = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2612,11 +2722,11 @@ static int __pyx_pw_5_cdec_11DenseVector_9__setitem__(PyObject *__pyx_v_self, Py return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":24 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":25 * raise KeyError(fname) * * def __setitem__(self, char* fname, float value): # <<<<<<<<<<<<<< - * cdef int fid = FDConvert(<char *>fname) + * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) */ @@ -2632,43 +2742,43 @@ static int __pyx_pf_5_cdec_11DenseVector_8__setitem__(struct __pyx_obj_5_cdec_De int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":25 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":26 * * def __setitem__(self, char* fname, float value): - * cdef int fid = FDConvert(<char *>fname) # <<<<<<<<<<<<<< + * cdef int fid = FDConvert(fname) # <<<<<<<<<<<<<< * if fid < 0: raise KeyError(fname) * if self.vector.size() <= fid: */ - __pyx_v_fid = FD::Convert(((char *)__pyx_v_fname)); + __pyx_v_fid = FD::Convert(__pyx_v_fname); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":26 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":27 * def __setitem__(self, char* fname, float value): - * cdef int fid = FDConvert(<char *>fname) + * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<< * if self.vector.size() <= fid: * self.vector.resize(fid + 1) */ __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 = 26; __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 = 27; __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 = 26; __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 = 27; __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 = 26; __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 = 27; __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 = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":27 - * cdef int fid = FDConvert(<char *>fname) + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":28 + * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) * if self.vector.size() <= fid: # <<<<<<<<<<<<<< * self.vector.resize(fid + 1) @@ -2677,7 +2787,7 @@ static int __pyx_pf_5_cdec_11DenseVector_8__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":28 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":29 * if fid < 0: raise KeyError(fname) * if self.vector.size() <= fid: * self.vector.resize(fid + 1) # <<<<<<<<<<<<<< @@ -2689,7 +2799,7 @@ static int __pyx_pf_5_cdec_11DenseVector_8__setitem__(struct __pyx_obj_5_cdec_De } __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":29 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":30 * if self.vector.size() <= fid: * self.vector.resize(fid + 1) * self.vector[0][fid] = value # <<<<<<<<<<<<<< @@ -2722,7 +2832,7 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_11__iter__(PyObject *__pyx_v_self return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":31 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":32 * self.vector[0][fid] = value * * def __iter__(self): # <<<<<<<<<<<<<< @@ -2748,7 +2858,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_10__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_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_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 = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -2785,34 +2895,42 @@ static PyObject *__pyx_gb_5_cdec_11DenseVector_12generator(__pyx_GeneratorObject return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":33 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":34 * def __iter__(self): * cdef unsigned fid * for fid in range(1, self.vector.size()): # <<<<<<<<<<<<<< - * yield FDConvert(fid).c_str(), self.vector[0][fid] + * yield str(FDConvert(fid).c_str()), self.vector[0][fid] * */ __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->vector->size(); 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":34 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":35 * cdef unsigned fid * for fid in range(1, self.vector.size()): - * yield FDConvert(fid).c_str(), self.vector[0][fid] # <<<<<<<<<<<<<< + * yield str(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 = 34; __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 = 35; __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 = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __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 = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_3)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3)); __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __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 = 35; __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 = 35; __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); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_3 = 0; @@ -2829,7 +2947,7 @@ static PyObject *__pyx_gb_5_cdec_11DenseVector_12generator(__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 = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -2848,11 +2966,12 @@ static PyObject *__pyx_gb_5_cdec_11DenseVector_12generator(__pyx_GeneratorObject /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_11DenseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/ +static char __pyx_doc_5_cdec_11DenseVector_13dot[] = "vector.dot(SparseVector other) -> Dot product of the two vectors."; 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 = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __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:; @@ -2862,12 +2981,12 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_14dot(PyObject *__pyx_v_self, PyO return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":36 - * yield FDConvert(fid).c_str(), self.vector[0][fid] +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":37 + * yield str(FDConvert(fid).c_str()), self.vector[0][fid] * * def dot(self, SparseVector other): # <<<<<<<<<<<<<< + * """vector.dot(SparseVector other) -> Dot product of the two vectors.""" * return other.dot(self) - * */ 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) { @@ -2881,22 +3000,22 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_13dot(struct __pyx_obj_5_cdec_Den int __pyx_clineno = 0; __Pyx_RefNannySetupContext("dot", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":37 - * + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":39 * def dot(self, SparseVector other): + * """vector.dot(SparseVector other) -> Dot product of the two vectors.""" * return other.dot(self) # <<<<<<<<<<<<<< * * 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 = 37; __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 = 39; __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 = 37; __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 = 39; __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 = 37; __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 = 39; __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; @@ -2920,6 +3039,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_13dot(struct __pyx_obj_5_cdec_Den /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_11DenseVector_16tosparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_11DenseVector_15tosparse[] = "vector.tosparse() -> Equivalent SparseVector."; static PyObject *__pyx_pw_5_cdec_11DenseVector_16tosparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -2929,12 +3049,12 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_16tosparse(PyObject *__pyx_v_self return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":39 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":41 * return other.dot(self) * * def tosparse(self): # <<<<<<<<<<<<<< + * """vector.tosparse() -> Equivalent SparseVector.""" * cdef SparseVector sparse = SparseVector.__new__(SparseVector) - * sparse.vector = new FastSparseVector[weight_t]() */ static PyObject *__pyx_pf_5_cdec_11DenseVector_15tosparse(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) { @@ -2947,21 +3067,21 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_15tosparse(struct __pyx_obj_5_cde int __pyx_clineno = 0; __Pyx_RefNannySetupContext("tosparse", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":40 - * + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":43 * def tosparse(self): + * """vector.tosparse() -> Equivalent SparseVector.""" * cdef SparseVector sparse = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * sparse.vector = new FastSparseVector[weight_t]() * InitSparseVector(self.vector[0], sparse.vector) */ - __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_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __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;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __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":41 - * def tosparse(self): + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":44 + * """vector.tosparse() -> Equivalent SparseVector.""" * cdef SparseVector sparse = SparseVector.__new__(SparseVector) * sparse.vector = new FastSparseVector[weight_t]() # <<<<<<<<<<<<<< * InitSparseVector(self.vector[0], sparse.vector) @@ -2969,7 +3089,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_15tosparse(struct __pyx_obj_5_cde */ __pyx_v_sparse->vector = new FastSparseVector<weight_t>(); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":42 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":45 * cdef SparseVector sparse = SparseVector.__new__(SparseVector) * sparse.vector = new FastSparseVector[weight_t]() * InitSparseVector(self.vector[0], sparse.vector) # <<<<<<<<<<<<<< @@ -2978,7 +3098,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_15tosparse(struct __pyx_obj_5_cde */ Weights::InitSparseVector((__pyx_v_self->vector[0]), __pyx_v_sparse->vector); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":43 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":46 * sparse.vector = new FastSparseVector[weight_t]() * InitSparseVector(self.vector[0], sparse.vector) * return sparse # <<<<<<<<<<<<<< @@ -3005,6 +3125,10 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_15tosparse(struct __pyx_obj_5_cde /* Python wrapper */ static int __pyx_pw_5_cdec_12SparseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_12SparseVector___init__[] = "SparseVector() -> Sparse feature/weight vector."; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_12SparseVector___init__; +#endif static int __pyx_pw_5_cdec_12SparseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations @@ -3017,12 +3141,12 @@ static int __pyx_pw_5_cdec_12SparseVector_1__init__(PyObject *__pyx_v_self, PyOb return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":48 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":51 * cdef FastSparseVector[weight_t]* vector * * def __init__(self): # <<<<<<<<<<<<<< + * """SparseVector() -> Sparse feature/weight vector.""" * self.vector = new FastSparseVector[weight_t]() - * */ static int __pyx_pf_5_cdec_12SparseVector___init__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) { @@ -3030,9 +3154,9 @@ static int __pyx_pf_5_cdec_12SparseVector___init__(struct __pyx_obj_5_cdec_Spars __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":49 - * + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":53 * def __init__(self): + * """SparseVector() -> Sparse feature/weight vector.""" * self.vector = new FastSparseVector[weight_t]() # <<<<<<<<<<<<<< * * def __dealloc__(self): @@ -3053,7 +3177,7 @@ static void __pyx_pw_5_cdec_12SparseVector_3__dealloc__(PyObject *__pyx_v_self) __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":51 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":55 * self.vector = new FastSparseVector[weight_t]() * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -3065,7 +3189,7 @@ static void __pyx_pf_5_cdec_12SparseVector_2__dealloc__(CYTHON_UNUSED struct __p __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":52 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":56 * * def __dealloc__(self): * del self.vector # <<<<<<<<<<<<<< @@ -3079,6 +3203,7 @@ static void __pyx_pf_5_cdec_12SparseVector_2__dealloc__(CYTHON_UNUSED struct __p /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_12SparseVector_5copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_12SparseVector_4copy[] = "vector.copy() -> SparseVector copy."; static PyObject *__pyx_pw_5_cdec_12SparseVector_5copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -3088,12 +3213,12 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_5copy(PyObject *__pyx_v_self, CY return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":54 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":58 * del self.vector * * def copy(self): # <<<<<<<<<<<<<< + * """vector.copy() -> SparseVector copy.""" * return self * 1 - * */ static PyObject *__pyx_pf_5_cdec_12SparseVector_4copy(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) { @@ -3105,15 +3230,15 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_4copy(struct __pyx_obj_5_cdec_Sp int __pyx_clineno = 0; __Pyx_RefNannySetupContext("copy", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":55 - * + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":60 * def copy(self): + * """vector.copy() -> SparseVector copy.""" * return self * 1 # <<<<<<<<<<<<<< * * 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 = 55; __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 = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3139,7 +3264,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_7__getitem__(PyObject *__pyx_v_s __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 = 57; __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;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -3152,7 +3277,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_7__getitem__(PyObject *__pyx_v_s return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":57 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":62 * return self * 1 * * def __getitem__(self, char* fname): # <<<<<<<<<<<<<< @@ -3172,7 +3297,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_6__getitem__(struct __pyx_obj_5_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":58 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":63 * * def __getitem__(self, char* fname): * cdef int fid = FDConvert(fname) # <<<<<<<<<<<<<< @@ -3181,7 +3306,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_6__getitem__(struct __pyx_obj_5_ */ __pyx_v_fid = FD::Convert(__pyx_v_fname); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":59 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":64 * def __getitem__(self, char* fname): * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<< @@ -3190,24 +3315,24 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_6__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 = 59; __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 = 59; __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 = 59; __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 = 59; __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":60 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":65 * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) * return self.vector.value(fid) # <<<<<<<<<<<<<< @@ -3215,7 +3340,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_6__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 = 60; __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 = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; @@ -3243,10 +3368,10 @@ static int __pyx_pw_5_cdec_12SparseVector_9__setitem__(PyObject *__pyx_v_self, P __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 = 62; __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 = 67; __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 = 62; __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 = 67; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -3259,11 +3384,11 @@ static int __pyx_pw_5_cdec_12SparseVector_9__setitem__(PyObject *__pyx_v_self, P return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":62 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":67 * return self.vector.value(fid) * * def __setitem__(self, char* fname, float value): # <<<<<<<<<<<<<< - * cdef int fid = FDConvert(<char *>fname) + * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) */ @@ -3279,43 +3404,43 @@ static int __pyx_pf_5_cdec_12SparseVector_8__setitem__(struct __pyx_obj_5_cdec_S int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":63 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":68 * * def __setitem__(self, char* fname, float value): - * cdef int fid = FDConvert(<char *>fname) # <<<<<<<<<<<<<< + * cdef int fid = FDConvert(fname) # <<<<<<<<<<<<<< * if fid < 0: raise KeyError(fname) * self.vector.set_value(fid, value) */ - __pyx_v_fid = FD::Convert(((char *)__pyx_v_fname)); + __pyx_v_fid = FD::Convert(__pyx_v_fname); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":64 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":69 * def __setitem__(self, char* fname, float value): - * cdef int fid = FDConvert(<char *>fname) + * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<< * self.vector.set_value(fid, value) * */ __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 = 64; __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 = 69; __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 = 64; __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 = 69; __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 = 64; __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 = 69; __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 = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":65 - * cdef int fid = FDConvert(<char *>fname) + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":70 + * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) * self.vector.set_value(fid, value) # <<<<<<<<<<<<<< * @@ -3347,7 +3472,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_11__iter__(PyObject *__pyx_v_sel return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":67 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":72 * self.vector.set_value(fid, value) * * def __iter__(self): # <<<<<<<<<<<<<< @@ -3373,7 +3498,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_10__iter__(struct __pyx_obj_5_cd __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_12generator1, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __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 = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -3410,9 +3535,9 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__pyx_GeneratorObje return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":68 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":73 * * def __iter__(self): * cdef FastSparseVector[weight_t].const_iterator* it = new FastSparseVector[weight_t].const_iterator(self.vector[0], False) # <<<<<<<<<<<<<< @@ -3421,41 +3546,49 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__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":70 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":75 * cdef FastSparseVector[weight_t].const_iterator* it = new FastSparseVector[weight_t].const_iterator(self.vector[0], False) * cdef unsigned i * try: # <<<<<<<<<<<<<< * for i in range(self.vector.size()): - * yield (FDConvert(it[0].ptr().first).c_str(), it[0].ptr().second) + * yield (str(FDConvert(it[0].ptr().first).c_str()), it[0].ptr().second) */ /*try:*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":71 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":76 * cdef unsigned i * try: * for i in range(self.vector.size()): # <<<<<<<<<<<<<< - * yield (FDConvert(it[0].ptr().first).c_str(), it[0].ptr().second) + * yield (str(FDConvert(it[0].ptr().first).c_str()), it[0].ptr().second) * pinc(it[0]) # ++it */ __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->vector->size(); 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":72 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":77 * try: * for i in range(self.vector.size()): - * yield (FDConvert(it[0].ptr().first).c_str(), it[0].ptr().second) # <<<<<<<<<<<<<< + * yield (str(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 = 72; __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 = 77; __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 = 72; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __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 = 72; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_GOTREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_3)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3)); __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __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 = 77; __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 = 77; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_3 = 0; @@ -3472,11 +3605,11 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__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 = 72; __pyx_clineno = __LINE__; goto __pyx_L5;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L5;} - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":73 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":78 * for i in range(self.vector.size()): - * yield (FDConvert(it[0].ptr().first).c_str(), it[0].ptr().second) + * yield (str(FDConvert(it[0].ptr().first).c_str()), it[0].ptr().second) * pinc(it[0]) # ++it # <<<<<<<<<<<<<< * finally: * del it @@ -3485,7 +3618,7 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__pyx_GeneratorObje } } - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":75 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":80 * pinc(it[0]) # ++it * finally: * del it # <<<<<<<<<<<<<< @@ -3537,6 +3670,7 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__pyx_GeneratorObje /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_12SparseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/ +static char __pyx_doc_5_cdec_12SparseVector_13dot[] = "vector.dot(SparseVector/DenseVector other) -> Dot product of the two vectors."; static PyObject *__pyx_pw_5_cdec_12SparseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -3546,12 +3680,12 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_14dot(PyObject *__pyx_v_self, Py return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":77 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":82 * del it * * def dot(self, other): # <<<<<<<<<<<<<< + * """vector.dot(SparseVector/DenseVector other) -> Dot product of the two vectors.""" * if isinstance(other, DenseVector): - * return self.vector.dot((<DenseVector> other).vector[0]) */ static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, PyObject *__pyx_v_other) { @@ -3565,9 +3699,9 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(struct __pyx_obj_5_cdec_Sp int __pyx_clineno = 0; __Pyx_RefNannySetupContext("dot", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":78 - * + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":84 * def dot(self, other): + * """vector.dot(SparseVector/DenseVector other) -> Dot product of the two vectors.""" * if isinstance(other, DenseVector): # <<<<<<<<<<<<<< * return self.vector.dot((<DenseVector> other).vector[0]) * elif isinstance(other, SparseVector): @@ -3578,15 +3712,15 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(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":79 - * def dot(self, other): + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":85 + * """vector.dot(SparseVector/DenseVector other) -> Dot product of the two vectors.""" * if isinstance(other, DenseVector): * return self.vector.dot((<DenseVector> other).vector[0]) # <<<<<<<<<<<<<< * elif isinstance(other, SparseVector): * 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 = 79; __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 = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3594,7 +3728,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(struct __pyx_obj_5_cdec_Sp goto __pyx_L3; } - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":80 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":86 * if isinstance(other, DenseVector): * return self.vector.dot((<DenseVector> other).vector[0]) * elif isinstance(other, SparseVector): # <<<<<<<<<<<<<< @@ -3607,7 +3741,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(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":81 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":87 * return self.vector.dot((<DenseVector> other).vector[0]) * elif isinstance(other, SparseVector): * return self.vector.dot((<SparseVector> other).vector[0]) # <<<<<<<<<<<<<< @@ -3615,7 +3749,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(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 = 81; __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 = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3624,26 +3758,26 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(struct __pyx_obj_5_cdec_Sp } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":82 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":88 * 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 = 82; __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 = 88; __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 = 82; __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 = 88; __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 = 82; __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 = 88; __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 = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; @@ -3664,8 +3798,8 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_16__richcmp__(PyObject *__pyx_v_ 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 = 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;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 90; __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 = 90; __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:; @@ -3675,7 +3809,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_16__richcmp__(PyObject *__pyx_v_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":84 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":90 * raise TypeError('cannot take the dot product of %s and SparseVector' % type(other)) * * def __richcmp__(SparseVector x, SparseVector y, int op): # <<<<<<<<<<<<<< @@ -3693,7 +3827,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__richcmp__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":87 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":93 * if op == 2: # == * return x.vector[0] == y.vector[0] * elif op == 3: # != # <<<<<<<<<<<<<< @@ -3702,7 +3836,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5 */ switch (__pyx_v_op) { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":85 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":91 * * def __richcmp__(SparseVector x, SparseVector y, int op): * if op == 2: # == # <<<<<<<<<<<<<< @@ -3711,7 +3845,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5 */ case 2: - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":86 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":92 * def __richcmp__(SparseVector x, SparseVector y, int op): * if op == 2: # == * return x.vector[0] == y.vector[0] # <<<<<<<<<<<<<< @@ -3719,14 +3853,14 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_15__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 = 86; __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 = 92; __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":87 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":93 * if op == 2: # == * return x.vector[0] == y.vector[0] * elif op == 3: # != # <<<<<<<<<<<<<< @@ -3735,7 +3869,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5 */ case 3: - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":88 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":94 * return x.vector[0] == y.vector[0] * elif op == 3: # != * return not (x == y) # <<<<<<<<<<<<<< @@ -3743,11 +3877,10 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_15__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 = 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 = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 94; __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 = 94; __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 = 88; __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 = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3755,18 +3888,18 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5 break; } - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":89 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":95 * 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 = 89; __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 = 95; __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 = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; @@ -3791,7 +3924,7 @@ static Py_ssize_t __pyx_pw_5_cdec_12SparseVector_18__len__(PyObject *__pyx_v_sel return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":91 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":97 * raise NotImplemented('comparison not implemented for SparseVector') * * def __len__(self): # <<<<<<<<<<<<<< @@ -3804,7 +3937,7 @@ static Py_ssize_t __pyx_pf_5_cdec_12SparseVector_17__len__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":92 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":98 * * def __len__(self): * return self.vector.size() # <<<<<<<<<<<<<< @@ -3828,7 +3961,7 @@ static int __pyx_pw_5_cdec_12SparseVector_20__contains__(PyObject *__pyx_v_self, __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 = 94; __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 = 100; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -3841,7 +3974,7 @@ static int __pyx_pw_5_cdec_12SparseVector_20__contains__(PyObject *__pyx_v_self, return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":94 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":100 * return self.vector.size() * * def __contains__(self, char* fname): # <<<<<<<<<<<<<< @@ -3854,7 +3987,7 @@ static int __pyx_pf_5_cdec_12SparseVector_19__contains__(struct __pyx_obj_5_cdec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__contains__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":95 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":101 * * def __contains__(self, char* fname): * return self.vector.nonzero(FDConvert(fname)) # <<<<<<<<<<<<<< @@ -3881,7 +4014,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_22__neg__(PyObject *__pyx_v_self return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":97 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":103 * return self.vector.nonzero(FDConvert(fname)) * * def __neg__(self): # <<<<<<<<<<<<<< @@ -3899,20 +4032,20 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_21__neg__(struct __pyx_obj_5_cde int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__neg__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":98 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":104 * * def __neg__(self): * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * result.vector = new FastSparseVector[weight_t](self.vector[0]) * result.vector[0] *= -1.0 */ - __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_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __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;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __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":99 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":105 * def __neg__(self): * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](self.vector[0]) # <<<<<<<<<<<<<< @@ -3921,7 +4054,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_21__neg__(struct __pyx_obj_5_cde */ __pyx_v_result->vector = new FastSparseVector<weight_t>((__pyx_v_self->vector[0])); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":100 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":106 * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](self.vector[0]) * result.vector[0] *= -1.0 # <<<<<<<<<<<<<< @@ -3930,7 +4063,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_21__neg__(struct __pyx_obj_5_cde */ (__pyx_v_result->vector[0]) *= -1.0; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":101 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":107 * result.vector = new FastSparseVector[weight_t](self.vector[0]) * result.vector[0] *= -1.0 * return result # <<<<<<<<<<<<<< @@ -3961,7 +4094,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_24__iadd__(PyObject *__pyx_v_sel 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 = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 109; __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:; @@ -3971,7 +4104,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_24__iadd__(PyObject *__pyx_v_sel return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":103 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":109 * return result * * def __iadd__(SparseVector self, SparseVector other): # <<<<<<<<<<<<<< @@ -3984,7 +4117,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_23__iadd__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__iadd__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":104 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":110 * * def __iadd__(SparseVector self, SparseVector other): * self.vector[0] += other.vector[0] # <<<<<<<<<<<<<< @@ -3993,7 +4126,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_23__iadd__(struct __pyx_obj_5_cd */ (__pyx_v_self->vector[0]) += (__pyx_v_other->vector[0]); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":105 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":111 * def __iadd__(SparseVector self, SparseVector other): * self.vector[0] += other.vector[0] * return self # <<<<<<<<<<<<<< @@ -4018,7 +4151,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_26__isub__(PyObject *__pyx_v_sel 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 = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __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:; @@ -4028,7 +4161,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_26__isub__(PyObject *__pyx_v_sel return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":107 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":113 * return self * * def __isub__(SparseVector self, SparseVector other): # <<<<<<<<<<<<<< @@ -4041,7 +4174,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_25__isub__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__isub__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":108 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":114 * * def __isub__(SparseVector self, SparseVector other): * self.vector[0] -= other.vector[0] # <<<<<<<<<<<<<< @@ -4050,7 +4183,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_25__isub__(struct __pyx_obj_5_cd */ (__pyx_v_self->vector[0]) -= (__pyx_v_other->vector[0]); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":109 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":115 * def __isub__(SparseVector self, SparseVector other): * self.vector[0] -= other.vector[0] * return self # <<<<<<<<<<<<<< @@ -4077,7 +4210,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_28__imul__(PyObject *__pyx_v_sel __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 = 111; __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 = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -4090,7 +4223,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_28__imul__(PyObject *__pyx_v_sel return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":111 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":117 * return self * * def __imul__(SparseVector self, float scalar): # <<<<<<<<<<<<<< @@ -4103,7 +4236,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_27__imul__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__imul__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":112 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":118 * * def __imul__(SparseVector self, float scalar): * self.vector[0] *= scalar # <<<<<<<<<<<<<< @@ -4112,7 +4245,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_27__imul__(struct __pyx_obj_5_cd */ (__pyx_v_self->vector[0]) *= __pyx_v_scalar; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":113 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":119 * def __imul__(SparseVector self, float scalar): * self.vector[0] *= scalar * return self # <<<<<<<<<<<<<< @@ -4140,7 +4273,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_30__idiv__(PyObject *__pyx_v_sel __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 = 115; __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 = 121; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -4154,7 +4287,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_30__idiv__(PyObject *__pyx_v_sel } #endif /*!(#if PY_MAJOR_VERSION < 3)*/ -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":115 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":121 * return self * * def __idiv__(SparseVector self, float scalar): # <<<<<<<<<<<<<< @@ -4168,7 +4301,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_29__idiv__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__idiv__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":116 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":122 * * def __idiv__(SparseVector self, float scalar): * self.vector[0] /= scalar # <<<<<<<<<<<<<< @@ -4177,7 +4310,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_29__idiv__(struct __pyx_obj_5_cd */ (__pyx_v_self->vector[0]) /= __pyx_v_scalar; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":117 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":123 * def __idiv__(SparseVector self, float scalar): * self.vector[0] /= scalar * return self # <<<<<<<<<<<<<< @@ -4203,8 +4336,8 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_32__add__(PyObject *__pyx_v_x, P 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 = 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;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __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 = 125; __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:; @@ -4214,7 +4347,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_32__add__(PyObject *__pyx_v_x, P return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":119 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":125 * return self * * def __add__(SparseVector x, SparseVector y): # <<<<<<<<<<<<<< @@ -4232,20 +4365,20 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_31__add__(struct __pyx_obj_5_cde int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__add__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":120 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":126 * * def __add__(SparseVector x, SparseVector y): * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0]) * return result */ - __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_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 126; __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;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 126; __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":121 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":127 * def __add__(SparseVector x, SparseVector y): * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0]) # <<<<<<<<<<<<<< @@ -4254,7 +4387,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_31__add__(struct __pyx_obj_5_cde */ __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":122 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":128 * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0]) * return result # <<<<<<<<<<<<<< @@ -4285,8 +4418,8 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_34__sub__(PyObject *__pyx_v_x, P 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 = 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;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __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 = 130; __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:; @@ -4296,7 +4429,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_34__sub__(PyObject *__pyx_v_x, P return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":124 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":130 * return result * * def __sub__(SparseVector x, SparseVector y): # <<<<<<<<<<<<<< @@ -4314,20 +4447,20 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_33__sub__(struct __pyx_obj_5_cde int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__sub__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":125 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":131 * * def __sub__(SparseVector x, SparseVector y): * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0]) * return result */ - __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_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 131; __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;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 131; __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":126 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":132 * def __sub__(SparseVector x, SparseVector y): * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0]) # <<<<<<<<<<<<<< @@ -4336,7 +4469,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_33__sub__(struct __pyx_obj_5_cde */ __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":127 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":133 * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0]) * return result # <<<<<<<<<<<<<< @@ -4372,7 +4505,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_36__mul__(PyObject *__pyx_v_x, P return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":129 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":135 * return result * * def __mul__(x, y): # <<<<<<<<<<<<<< @@ -4394,7 +4527,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_35__mul__(PyObject *__pyx_v_x, P int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__mul__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":132 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":138 * cdef SparseVector vector * cdef float scalar * if isinstance(x, SparseVector): vector, scalar = x, y # <<<<<<<<<<<<<< @@ -4406,10 +4539,10 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_35__mul__(PyObject *__pyx_v_x, P __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 = 132; __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 = 138; __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 = 132; __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 = 138; __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; @@ -4417,37 +4550,37 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_35__mul__(PyObject *__pyx_v_x, P } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":133 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":139 * cdef float scalar * if isinstance(x, SparseVector): vector, scalar = x, y * else: vector, scalar = y, x # <<<<<<<<<<<<<< * 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 = 133; __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 = 139; __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 = 133; __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 = 139; __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":134 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":140 * if isinstance(x, SparseVector): vector, scalar = x, y * else: vector, scalar = y, x * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar) * return result */ - __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_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 140; __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;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 140; __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":135 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":141 * else: vector, scalar = y, x * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar) # <<<<<<<<<<<<<< @@ -4456,7 +4589,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_35__mul__(PyObject *__pyx_v_x, P */ __pyx_v_result->vector = new FastSparseVector<weight_t>(((__pyx_v_vector->vector[0]) * __pyx_v_scalar)); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":136 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":142 * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar) * return result # <<<<<<<<<<<<<< @@ -4495,7 +4628,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_38__div__(PyObject *__pyx_v_x, P } #endif /*!(#if PY_MAJOR_VERSION < 3)*/ -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":138 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":144 * return result * * def __div__(x, y): # <<<<<<<<<<<<<< @@ -4518,7 +4651,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_37__div__(PyObject *__pyx_v_x, P int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__div__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":141 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":147 * cdef SparseVector vector * cdef float scalar * if isinstance(x, SparseVector): vector, scalar = x, y # <<<<<<<<<<<<<< @@ -4530,10 +4663,10 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_37__div__(PyObject *__pyx_v_x, P __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 = 141; __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 = 147; __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 = 141; __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 = 147; __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; @@ -4541,37 +4674,37 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_37__div__(PyObject *__pyx_v_x, P } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":142 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":148 * cdef float scalar * if isinstance(x, SparseVector): vector, scalar = x, y * else: vector, scalar = y, x # <<<<<<<<<<<<<< * 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 = 142; __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 = 148; __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 = 142; __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 = 148; __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":143 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":149 * if isinstance(x, SparseVector): vector, scalar = x, y * else: vector, scalar = y, x * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar) * return result */ - __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_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __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;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __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":144 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":150 * else: vector, scalar = y, x * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar) # <<<<<<<<<<<<<< @@ -4579,7 +4712,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_37__div__(PyObject *__pyx_v_x, P */ __pyx_v_result->vector = new FastSparseVector<weight_t>(((__pyx_v_vector->vector[0]) / __pyx_v_scalar)); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":145 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":151 * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar) * return result # <<<<<<<<<<<<<< @@ -4615,9 +4748,9 @@ static PyObject *__pyx_pw_5_cdec_1_phrase(PyObject *__pyx_self, PyObject *__pyx_ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_7_phrase_2generator17(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_5_cdec_7_phrase_2generator18(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":6 +/* "/home/vchahune/tools/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) # <<<<<<<<<<<<<< @@ -4643,7 +4776,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 = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7_phrase_2generator18, (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; @@ -4661,7 +4794,7 @@ static PyObject *__pyx_pf_5_cdec_7_phrase_genexpr(PyObject *__pyx_self) { return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_7_phrase_2generator17(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_7_phrase_2generator18(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr *)__pyx_generator->closure); PyObject *__pyx_r = NULL; @@ -4696,16 +4829,16 @@ static PyObject *__pyx_gb_5_cdec_7_phrase_2generator17(__pyx_GeneratorObject *__ 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++; + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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++; + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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); @@ -4783,7 +4916,7 @@ static PyObject *__pyx_gb_5_cdec_7_phrase_2generator17(__pyx_GeneratorObject *__ return NULL; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":5 * import cdec.sa._sa as _sa * * def _phrase(phrase): # <<<<<<<<<<<<<< @@ -4812,7 +4945,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":6 + /* "/home/vchahune/tools/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) # <<<<<<<<<<<<<< @@ -4854,8 +4987,12 @@ static PyObject *__pyx_pf_5_cdec__phrase(CYTHON_UNUSED PyObject *__pyx_self, PyO /* Python wrapper */ static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_2NT___init__[] = "NT(bytes cat, int ref=0) -> Non-terminal from category `cat`."; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_2NT___init__; +#endif static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - char *__pyx_v_cat; + PyObject *__pyx_v_cat = 0; unsigned int __pyx_v_ref; int __pyx_r; __Pyx_RefNannyDeclarations @@ -4894,7 +5031,7 @@ static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx default: goto __pyx_L5_argtuple_error; } } - __pyx_v_cat = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_cat) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_cat = ((PyObject*)values[0]); if (values[1]) { __pyx_v_ref = __Pyx_PyInt_AsUnsignedInt(values[1]); if (unlikely((__pyx_v_ref == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { @@ -4909,45 +5046,44 @@ static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cat), (&PyBytes_Type), 1, "cat", 1))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_5_cdec_2NT___init__(((struct __pyx_obj_5_cdec_NT *)__pyx_v_self), __pyx_v_cat, __pyx_v_ref); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":11 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":11 * cdef public bytes cat * cdef public unsigned ref - * def __init__(self, char* cat, unsigned ref=0): # <<<<<<<<<<<<<< + * def __init__(self, bytes cat, unsigned ref=0): # <<<<<<<<<<<<<< + * """NT(bytes cat, int ref=0) -> Non-terminal from category `cat`.""" * self.cat = cat - * self.ref = ref */ -static int __pyx_pf_5_cdec_2NT___init__(struct __pyx_obj_5_cdec_NT *__pyx_v_self, char *__pyx_v_cat, unsigned int __pyx_v_ref) { +static int __pyx_pf_5_cdec_2NT___init__(struct __pyx_obj_5_cdec_NT *__pyx_v_self, PyObject *__pyx_v_cat, unsigned int __pyx_v_ref) { int __pyx_r; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - 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":12 - * cdef public unsigned ref - * def __init__(self, char* cat, unsigned ref=0): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":13 + * def __init__(self, bytes cat, unsigned ref=0): + * """NT(bytes cat, int ref=0) -> Non-terminal from category `cat`.""" * self.cat = cat # <<<<<<<<<<<<<< * self.ref = ref * */ - __pyx_t_1 = PyBytes_FromString(__pyx_v_cat); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __Pyx_INCREF(((PyObject *)__pyx_v_cat)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_cat)); __Pyx_GOTREF(__pyx_v_self->cat); __Pyx_DECREF(((PyObject *)__pyx_v_self->cat)); - __pyx_v_self->cat = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_v_self->cat = __pyx_v_cat; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":13 - * def __init__(self, char* cat, unsigned ref=0): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":14 + * """NT(bytes cat, int ref=0) -> Non-terminal from category `cat`.""" * self.cat = cat * self.ref = ref # <<<<<<<<<<<<<< * @@ -4956,12 +5092,6 @@ static int __pyx_pf_5_cdec_2NT___init__(struct __pyx_obj_5_cdec_NT *__pyx_v_self __pyx_v_self->ref = __pyx_v_ref; __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("_cdec.NT.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -4977,7 +5107,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":15 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":16 * self.ref = ref * * def __str__(self): # <<<<<<<<<<<<<< @@ -4996,7 +5126,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":16 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":17 * * def __str__(self): * if self.ref > 0: # <<<<<<<<<<<<<< @@ -5006,7 +5136,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":17 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":18 * def __str__(self): * if self.ref > 0: * return '[%s,%d]' % (self.cat, self.ref) # <<<<<<<<<<<<<< @@ -5014,9 +5144,9 @@ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_ * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_self->cat)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->cat)); @@ -5024,7 +5154,7 @@ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_ PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_r = ((PyObject *)__pyx_t_2); @@ -5034,7 +5164,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":18 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":19 * if self.ref > 0: * return '[%s,%d]' % (self.cat, self.ref) * return '[%s]' % self.cat # <<<<<<<<<<<<<< @@ -5042,7 +5172,7 @@ 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_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), ((PyObject *)__pyx_v_self->cat)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), ((PyObject *)__pyx_v_self->cat)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); __pyx_r = ((PyObject *)__pyx_t_2); __pyx_t_2 = 0; @@ -5072,12 +5202,12 @@ 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":9 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":9 * * cdef class NT: * cdef public bytes cat # <<<<<<<<<<<<<< * cdef public unsigned ref - * def __init__(self, char* cat, unsigned ref=0): + * def __init__(self, bytes cat, unsigned ref=0): */ static PyObject *__pyx_pf_5_cdec_2NT_3cat___get__(struct __pyx_obj_5_cdec_NT *__pyx_v_self) { @@ -5168,12 +5298,12 @@ 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":10 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":10 * cdef class NT: * cdef public bytes cat * cdef public unsigned ref # <<<<<<<<<<<<<< - * def __init__(self, char* cat, unsigned ref=0): - * self.cat = cat + * def __init__(self, bytes cat, unsigned ref=0): + * """NT(bytes cat, int ref=0) -> Non-terminal from category `cat`.""" */ static PyObject *__pyx_pf_5_cdec_2NT_3ref___get__(struct __pyx_obj_5_cdec_NT *__pyx_v_self) { @@ -5237,6 +5367,10 @@ static int __pyx_pf_5_cdec_2NT_3ref_2__set__(struct __pyx_obj_5_cdec_NT *__pyx_v /* Python wrapper */ static int __pyx_pw_5_cdec_5NTRef_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_5NTRef___init__[] = "NTRef(int ref) -> Non-terminal reference."; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_5NTRef___init__; +#endif static int __pyx_pw_5_cdec_5NTRef_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { unsigned int __pyx_v_ref; int __pyx_r; @@ -5260,18 +5394,18 @@ static int __pyx_pw_5_cdec_5NTRef_1__init__(PyObject *__pyx_v_self, PyObject *__ 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 = 22; __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 = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } - __pyx_v_ref = __Pyx_PyInt_AsUnsignedInt(values[0]); if (unlikely((__pyx_v_ref == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_ref = __Pyx_PyInt_AsUnsignedInt(values[0]); if (unlikely((__pyx_v_ref == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } 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 = 22; __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 = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.NTRef.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -5282,12 +5416,12 @@ 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":22 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":23 * cdef class NTRef: * cdef public unsigned ref * def __init__(self, unsigned ref): # <<<<<<<<<<<<<< + * """NTRef(int ref) -> Non-terminal reference.""" * self.ref = ref - * */ static int __pyx_pf_5_cdec_5NTRef___init__(struct __pyx_obj_5_cdec_NTRef *__pyx_v_self, unsigned int __pyx_v_ref) { @@ -5295,9 +5429,9 @@ static int __pyx_pf_5_cdec_5NTRef___init__(struct __pyx_obj_5_cdec_NTRef *__pyx_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":23 - * cdef public unsigned ref + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":25 * def __init__(self, unsigned ref): + * """NTRef(int ref) -> Non-terminal reference.""" * self.ref = ref # <<<<<<<<<<<<<< * * def __str__(self): @@ -5320,7 +5454,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":25 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":27 * self.ref = ref * * def __str__(self): # <<<<<<<<<<<<<< @@ -5338,7 +5472,7 @@ 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":26 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":28 * * def __str__(self): * return '[%d]' % self.ref # <<<<<<<<<<<<<< @@ -5346,9 +5480,9 @@ static PyObject *__pyx_pf_5_cdec_5NTRef_2__str__(struct __pyx_obj_5_cdec_NTRef * * 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 = 26; __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 = 28; __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 = 26; __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 = 28; __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); @@ -5379,12 +5513,12 @@ 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":21 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":22 * * cdef class NTRef: * cdef public unsigned ref # <<<<<<<<<<<<<< * def __init__(self, unsigned ref): - * self.ref = ref + * """NTRef(int ref) -> Non-terminal reference.""" */ static PyObject *__pyx_pf_5_cdec_5NTRef_3ref___get__(struct __pyx_obj_5_cdec_NTRef *__pyx_v_self) { @@ -5396,7 +5530,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 = 21; __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 = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -5433,7 +5567,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 = 21; __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 = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->ref = __pyx_t_1; __pyx_r = 0; @@ -5446,122 +5580,81 @@ 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 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":30 * return '[%d]' % self.ref * * cdef TRule convert_rule(_sa.Rule rule): # <<<<<<<<<<<<<< - * cdef unsigned i - * cdef lhs = _sa.sym_tocat(rule.lhs) + * lhs = _sa.sym_tocat(rule.lhs) + * scores = dict(rule.scores) */ 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; + char *__pyx_v_lhs; + PyObject *__pyx_v_scores = NULL; PyObject *__pyx_v_f = NULL; PyObject *__pyx_v_e = NULL; int *__pyx_v_fsyms; + int __pyx_v_i; int *__pyx_v_esyms; - PyObject *__pyx_v_a = 0; - PyObject *__pyx_v_point = NULL; + PyObject *__pyx_v_a = 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; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; 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 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":31 + * * 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] + * lhs = _sa.sym_tocat(rule.lhs) # <<<<<<<<<<<<<< + * scores = dict(rule.scores) * 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; + __pyx_v_lhs = __pyx_f_4cdec_2sa_3_sa_sym_tocat(__pyx_v_rule->lhs); - /* "/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] # <<<<<<<<<<<<<< + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":32 + * cdef TRule convert_rule(_sa.Rule rule): + * lhs = _sa.sym_tocat(rule.lhs) + * scores = dict(rule.scores) # <<<<<<<<<<<<<< * 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; - } + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_rule->scores)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_rule->scores)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_rule->scores)); + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyDict_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_v_scores = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":34 - * for i in range(rule.n_scores): - * scores['PhraseModel_'+str(i)] = rule.cscores[i] + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":33 + * lhs = _sa.sym_tocat(rule.lhs) + * scores = dict(rule.scores) * 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_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyList_New(0); 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_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_v_f = __pyx_t_2; + __pyx_t_2 = 0; + __pyx_v_e = __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] + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":34 + * scores = dict(rule.scores) * f, e = [], [] * cdef int* fsyms = rule.f.syms # <<<<<<<<<<<<<< * for i in range(rule.f.n): @@ -5569,66 +5662,66 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o */ __pyx_v_fsyms = __pyx_v_rule->f->syms; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":36 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":35 * 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; + __pyx_t_3 = __pyx_v_rule->f->n; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":37 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":36 * 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) { + __pyx_t_5 = __pyx_f_4cdec_2sa_3_sa_sym_isvar((__pyx_v_fsyms[__pyx_v_i])); + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":38 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":37 * 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_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tocat((__pyx_v_fsyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 37; __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 = 37; __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 = 37; __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; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_6 = PyList_Append(__pyx_v_f, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L5; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":40 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":39 * 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_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tostring((__pyx_v_fsyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_6 = PyList_Append(__pyx_v_f, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; } - __pyx_L7:; + __pyx_L5:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":41 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":40 * else: * f.append(_sa.sym_tostring(fsyms[i])) * cdef int* esyms = rule.e.syms # <<<<<<<<<<<<<< @@ -5637,180 +5730,134 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o */ __pyx_v_esyms = __pyx_v_rule->e->syms; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":42 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":41 * 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; + __pyx_t_3 = __pyx_v_rule->e->n; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":43 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":42 * 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) { + __pyx_t_5 = __pyx_f_4cdec_2sa_3_sa_sym_isvar((__pyx_v_esyms[__pyx_v_i])); + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":44 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":43 * 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_t_1 = PyInt_FromLong(__pyx_f_4cdec_2sa_3_sa_sym_getindex((__pyx_v_esyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __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; + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 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_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_6 = PyList_Append(__pyx_v_e, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L8; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":46 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":45 * 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] + * a = list(rule.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_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tostring((__pyx_v_esyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_6 = PyList_Append(__pyx_v_e, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; } - __pyx_L10:; + __pyx_L8:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":47 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":46 * else: * e.append(_sa.sym_tostring(esyms[i])) - * cdef a = [(point/65536, point%65536) for point in rule.word_alignments] # <<<<<<<<<<<<<< + * a = list(rule.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_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_rule), __pyx_n_s__alignments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __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 = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); __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; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_v_a = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":48 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":47 * e.append(_sa.sym_tostring(esyms[i])) - * cdef a = [(point/65536, point%65536) for point in rule.word_alignments] + * a = list(rule.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_t_2 = PyBytes_FromString(__pyx_v_lhs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_1 = PyTuple_New(5); 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); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); __Pyx_INCREF(((PyObject *)__pyx_v_f)); - PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_f)); + PyTuple_SET_ITEM(__pyx_t_1, 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)); + PyTuple_SET_ITEM(__pyx_t_1, 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; + __Pyx_INCREF(((PyObject *)__pyx_v_scores)); + PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_v_scores)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_scores)); + __Pyx_INCREF(((PyObject *)__pyx_v_a)); + PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_v_a)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_a)); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TRule)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_r = ((struct __pyx_obj_5_cdec_TRule *)__pyx_t_2); + __pyx_t_2 = 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_XDECREF(__pyx_t_2); __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; @@ -5818,6 +5865,10 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o /* Python wrapper */ static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_5TRule___init__[] = "TRule(lhs, f, e, scores, a=None) -> Translation rule.\n lhs: left hand side non-terminal\n f: source phrase (list of words/NT)\n e: target phrase (list of words/NTRef)\n scores: dictionary of feature scores\n a: optional list of alignment points"; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_5TRule___init__; +#endif 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; @@ -5831,12 +5882,12 @@ static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__ 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 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":52 * 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 + * """TRule(lhs, f, e, scores, a=None) -> Translation rule. + * lhs: left hand side non-terminal */ values[4] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { @@ -5859,17 +5910,17 @@ static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__ 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;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __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;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __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;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: if (kw_args > 0) { @@ -5878,7 +5929,7 @@ static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__ } } 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;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -5899,7 +5950,7 @@ static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__ } 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_RaiseArgtupleInvalid("__init__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.TRule.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -5920,75 +5971,75 @@ static int __pyx_pf_5_cdec_5TRule___init__(struct __pyx_obj_5_cdec_TRule *__pyx_ 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): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":59 + * scores: dictionary of feature scores + * a: optional list of alignment points""" * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule()) # <<<<<<<<<<<<<< * self.lhs = lhs * self.e = e */ - try {__pyx_t_1 = new TRule();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + try {__pyx_t_1 = new TRule();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __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): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":60 + * a: optional list of alignment points""" * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule()) * self.lhs = lhs # <<<<<<<<<<<<<< * self.e = e * self.f = f */ - 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;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__lhs, __pyx_v_lhs) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":56 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":61 * 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;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__e, __pyx_v_e) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":57 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":62 * 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;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__f, __pyx_v_f) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":58 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":63 * 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;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__scores, __pyx_v_scores) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":59 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":64 * 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;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_a); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":60 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":65 * 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;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__a, __pyx_v_a) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":61 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":66 * if a: * self.a = a * self.rule.get().ComputeArity() # <<<<<<<<<<<<<< @@ -6016,7 +6067,7 @@ static void __pyx_pw_5_cdec_5TRule_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":63 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":68 * self.rule.get().ComputeArity() * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -6028,7 +6079,7 @@ static void __pyx_pf_5_cdec_5TRule_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5 __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":64 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":69 * * def __dealloc__(self): * del self.rule # <<<<<<<<<<<<<< @@ -6051,7 +6102,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_5arity_1__get__(PyObject *__pyx_v_self) return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":67 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":72 * * property arity: * def __get__(self): # <<<<<<<<<<<<<< @@ -6068,7 +6119,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_5arity___get__(struct __pyx_obj_5_cdec_T int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":68 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":73 * property arity: * def __get__(self): * return self.rule.get().arity_ # <<<<<<<<<<<<<< @@ -6076,7 +6127,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_5arity___get__(struct __pyx_obj_5_cdec_T * 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 = 68; __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 = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -6105,7 +6156,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_1f_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":71 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":76 * * property f: * def __get__(self): # <<<<<<<<<<<<<< @@ -6132,7 +6183,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":72 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":77 * property f: * def __get__(self): * cdef vector[WordID]* f_ = &self.rule.get().f_ # <<<<<<<<<<<<<< @@ -6141,19 +6192,19 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_f_ = (&__pyx_v_self->rule->get()->f_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":74 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":79 * 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 = 74; __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 = 79; __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":76 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":81 * cdef f = [] * cdef unsigned i * cdef int idx = 0 # <<<<<<<<<<<<<< @@ -6162,7 +6213,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_idx = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":77 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":82 * cdef unsigned i * cdef int idx = 0 * for i in range(f_.size()): # <<<<<<<<<<<<<< @@ -6173,7 +6224,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule 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":78 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":83 * cdef int idx = 0 * for i in range(f_.size()): * w = f_[0][i] # <<<<<<<<<<<<<< @@ -6182,37 +6233,37 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_w = ((__pyx_v_f_[0])[__pyx_v_i]); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":79 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":84 * for i in range(f_.size()): * w = f_[0][i] * if w < 0: # <<<<<<<<<<<<<< * idx += 1 - * f.append(NT(TDConvert(-w), idx)) + * f.append(NT(TDConvert(-w).c_str(), idx)) */ __pyx_t_4 = (__pyx_v_w < 0); if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":80 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":85 * w = f_[0][i] * if w < 0: * idx += 1 # <<<<<<<<<<<<<< - * f.append(NT(TDConvert(-w), idx)) + * f.append(NT(TDConvert(-w).c_str(), idx)) * else: */ __pyx_v_idx = (__pyx_v_idx + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":81 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":86 * if w < 0: * idx += 1 - * f.append(NT(TDConvert(-w), idx)) # <<<<<<<<<<<<<< + * f.append(NT(TDConvert(-w).c_str(), idx)) # <<<<<<<<<<<<<< * else: - * f.append(unicode(TDConvert(w), encoding='utf8')) + * f.append(unicode(TDConvert(w).c_str(), encoding='utf8')) */ - __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_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_w)).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 86; __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 = 81; __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 = 86; __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 = 81; __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 = 86; __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)); @@ -6220,10 +6271,10 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule __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 = 81; __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 = 86; __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 = 81; __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 = 86; __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; @@ -6231,28 +6282,28 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":83 - * f.append(NT(TDConvert(-w), idx)) + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":88 + * f.append(NT(TDConvert(-w).c_str(), idx)) * else: - * f.append(unicode(TDConvert(w), encoding='utf8')) # <<<<<<<<<<<<<< + * f.append(unicode(TDConvert(w).c_str(), 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 = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyBytes_FromString(TD::Convert(__pyx_v_w).c_str()); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __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 = 83; __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 = 88; __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 = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __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 = 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;} + if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __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 = 88; __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 = 83; __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 = 88; __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; @@ -6260,9 +6311,9 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule __pyx_L5:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":84 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":89 * else: - * f.append(unicode(TDConvert(w), encoding='utf8')) + * f.append(unicode(TDConvert(w).c_str(), encoding='utf8')) * return f # <<<<<<<<<<<<<< * * def __set__(self, f): @@ -6298,7 +6349,7 @@ static int __pyx_pw_5_cdec_5TRule_1f_3__set__(PyObject *__pyx_v_self, PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":86 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":91 * return f * * def __set__(self, f): # <<<<<<<<<<<<<< @@ -6310,6 +6361,7 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p std::vector<WordID> *__pyx_v_f_; unsigned int __pyx_v_i; CYTHON_UNUSED int __pyx_v_idx; + PyObject *__pyx_v_fi = NULL; int __pyx_r; __Pyx_RefNannyDeclarations Py_ssize_t __pyx_t_1; @@ -6323,7 +6375,7 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":87 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":92 * * def __set__(self, f): * cdef vector[WordID]* f_ = &self.rule.get().f_ # <<<<<<<<<<<<<< @@ -6332,17 +6384,17 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p */ __pyx_v_f_ = (&__pyx_v_self->rule->get()->f_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":88 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":93 * 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 = 88; __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 = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f_->resize(__pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":90 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":95 * f_.resize(len(f)) * cdef unsigned i * cdef int idx = 0 # <<<<<<<<<<<<<< @@ -6351,25 +6403,25 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p */ __pyx_v_idx = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":91 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":96 * 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) + * f_[0][i] = -TDConvert((<NT> f[i]).cat) */ - __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;} + __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 96; __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":92 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":97 * cdef int idx = 0 * for i in range(len(f)): * if isinstance(f[i], NT): # <<<<<<<<<<<<<< - * f_[0][i] = -TDConvert(<char *>f[i].cat) + * f_[0][i] = -TDConvert((<NT> 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 = 92; __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 = 97; __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); @@ -6378,36 +6430,47 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":93 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":98 * for i in range(len(f)): * if isinstance(f[i], NT): - * f_[0][i] = -TDConvert(<char *>f[i].cat) # <<<<<<<<<<<<<< + * f_[0][i] = -TDConvert((<NT> f[i]).cat) # <<<<<<<<<<<<<< * else: - * f_[0][i] = TDConvert(<char *>as_str(f[i])) + * fi = 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 = 93; __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 = 98; __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 = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyBytes_AsString(((PyObject *)((struct __pyx_obj_5_cdec_NT *)__pyx_t_4)->cat)); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __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 = 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))); + ((__pyx_v_f_[0])[__pyx_v_i]) = (-TD::Convert(__pyx_t_6)); goto __pyx_L5; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":95 - * f_[0][i] = -TDConvert(<char *>f[i].cat) + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":100 + * f_[0][i] = -TDConvert((<NT> f[i]).cat) * else: - * f_[0][i] = TDConvert(<char *>as_str(f[i])) # <<<<<<<<<<<<<< + * fi = as_str(f[i]) # <<<<<<<<<<<<<< + * f_[0][i] = TDConvert(fi) * - * 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 = 95; __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 = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_t_4, NULL)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 100; __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; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(((PyObject *)__pyx_v_fi)); + __pyx_v_fi = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":101 + * else: + * fi = as_str(f[i]) + * f_[0][i] = TDConvert(fi) # <<<<<<<<<<<<<< + * + * property e: + */ + __pyx_t_6 = PyBytes_AsString(((PyObject *)__pyx_v_fi)); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + ((__pyx_v_f_[0])[__pyx_v_i]) = TD::Convert(__pyx_t_6); } __pyx_L5:; } @@ -6420,6 +6483,7 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_AddTraceback("_cdec.TRule.f.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_fi); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -6435,7 +6499,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_1e_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":98 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":104 * * property e: * def __get__(self): # <<<<<<<<<<<<<< @@ -6462,7 +6526,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":99 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":105 * property e: * def __get__(self): * cdef vector[WordID]* e_ = &self.rule.get().e_ # <<<<<<<<<<<<<< @@ -6471,19 +6535,19 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_e_ = (&__pyx_v_self->rule->get()->e_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":101 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":107 * 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 = 101; __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 = 107; __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":103 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":109 * cdef e = [] * cdef unsigned i * cdef int idx = 0 # <<<<<<<<<<<<<< @@ -6492,7 +6556,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_idx = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":104 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":110 * cdef unsigned i * cdef int idx = 0 * for i in range(e_.size()): # <<<<<<<<<<<<<< @@ -6503,7 +6567,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule 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":105 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":111 * cdef int idx = 0 * for i in range(e_.size()): * w = e_[0][i] # <<<<<<<<<<<<<< @@ -6512,7 +6576,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_w = ((__pyx_v_e_[0])[__pyx_v_i]); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":106 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":112 * for i in range(e_.size()): * w = e_[0][i] * if w < 1: # <<<<<<<<<<<<<< @@ -6522,7 +6586,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule __pyx_t_4 = (__pyx_v_w < 1); if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":107 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":113 * w = e_[0][i] * if w < 1: * idx += 1 # <<<<<<<<<<<<<< @@ -6531,24 +6595,24 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_idx = (__pyx_v_idx + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":108 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":114 * if w < 1: * idx += 1 * e.append(NTRef(1-w)) # <<<<<<<<<<<<<< * else: - * e.append(unicode(TDConvert(w), encoding='utf8')) + * e.append(unicode(TDConvert(w).c_str(), encoding='utf8')) */ - __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_t_1 = PyInt_FromLong((1 - __pyx_v_w)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 114; __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 = 108; __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 = 114; __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 = 108; __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 = 114; __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 = 108; __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 = 114; __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; @@ -6556,28 +6620,28 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":110 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":116 * e.append(NTRef(1-w)) * else: - * e.append(unicode(TDConvert(w), encoding='utf8')) # <<<<<<<<<<<<<< + * e.append(unicode(TDConvert(w).c_str(), 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 = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyBytes_FromString(TD::Convert(__pyx_v_w).c_str()); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __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 = 110; __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 = 116; __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 = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __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 = 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;} + if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __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 = 116; __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 = 110; __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 = 116; __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; @@ -6585,9 +6649,9 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule __pyx_L5:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":111 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":117 * else: - * e.append(unicode(TDConvert(w), encoding='utf8')) + * e.append(unicode(TDConvert(w).c_str(), encoding='utf8')) * return e # <<<<<<<<<<<<<< * * def __set__(self, e): @@ -6623,7 +6687,7 @@ static int __pyx_pw_5_cdec_5TRule_1e_3__set__(PyObject *__pyx_v_self, PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":113 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":119 * return e * * def __set__(self, e): # <<<<<<<<<<<<<< @@ -6634,6 +6698,7 @@ static int __pyx_pw_5_cdec_5TRule_1e_3__set__(PyObject *__pyx_v_self, PyObject * 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; + PyObject *__pyx_v_ei = NULL; int __pyx_r; __Pyx_RefNannyDeclarations Py_ssize_t __pyx_t_1; @@ -6642,12 +6707,13 @@ static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__p PyObject *__pyx_t_4 = NULL; int __pyx_t_5; WordID __pyx_t_6; + char *__pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":114 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":120 * * def __set__(self, e): * cdef vector[WordID]* e_ = &self.rule.get().e_ # <<<<<<<<<<<<<< @@ -6656,35 +6722,35 @@ static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__p */ __pyx_v_e_ = (&__pyx_v_self->rule->get()->e_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":115 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":121 * 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 = 115; __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 = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_e_->resize(__pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":117 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":123 * 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 = 117; __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 = 123; __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":118 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":124 * 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 = 118; __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 = 124; __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); @@ -6693,39 +6759,53 @@ static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":119 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":125 * 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])) + * ei = 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 = 119; __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 = 125; __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 = 119; __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 = 125; __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 = 119; __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 = 125; __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 = 119; __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 = 125; __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":121 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":127 * e_[0][i] = 1-e[i].ref * else: - * e_[0][i] = TDConvert(<char *>as_str(e[i])) # <<<<<<<<<<<<<< + * ei = as_str(e[i]) # <<<<<<<<<<<<<< + * e_[0][i] = TDConvert(ei) * - * 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 = 121; __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 = 127; __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_t_3 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_t_4, NULL)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(((PyObject *)__pyx_v_ei)); + __pyx_v_ei = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":128 + * else: + * ei = as_str(e[i]) + * e_[0][i] = TDConvert(ei) # <<<<<<<<<<<<<< + * + * property a: + */ + __pyx_t_7 = PyBytes_AsString(((PyObject *)__pyx_v_ei)); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + ((__pyx_v_e_[0])[__pyx_v_i]) = TD::Convert(__pyx_t_7); } __pyx_L5:; } @@ -6738,6 +6818,7 @@ static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_AddTraceback("_cdec.TRule.e.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_ei); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -6754,7 +6835,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_1a_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":124 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":131 * * property a: * def __get__(self): # <<<<<<<<<<<<<< @@ -6780,7 +6861,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1a___get__(struct __pyx_obj_5_cdec_TRule __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_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_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 = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -6817,9 +6898,9 @@ static PyObject *__pyx_gb_5_cdec_5TRule_1a_2generator2(__pyx_GeneratorObject *__ return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":126 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":133 * def __get__(self): * cdef unsigned i * cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_ # <<<<<<<<<<<<<< @@ -6828,7 +6909,7 @@ static PyObject *__pyx_gb_5_cdec_5TRule_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":127 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":134 * cdef unsigned i * cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_ * for i in range(a.size()): # <<<<<<<<<<<<<< @@ -6839,18 +6920,18 @@ static PyObject *__pyx_gb_5_cdec_5TRule_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":128 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":135 * 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 = 128; __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 = 135; __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 = 128; __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 = 135; __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 = 128; __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 = 135; __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); @@ -6870,7 +6951,7 @@ static PyObject *__pyx_gb_5_cdec_5TRule_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 = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -6898,7 +6979,7 @@ static int __pyx_pw_5_cdec_5TRule_1a_4__set__(PyObject *__pyx_v_self, PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":130 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":137 * yield (a[0][i].s_, a[0][i].t_) * * def __set__(self, a): # <<<<<<<<<<<<<< @@ -6927,7 +7008,7 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":131 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":138 * * def __set__(self, a): * cdef vector[grammar.AlignmentPoint]* a_ = &self.rule.get().a_ # <<<<<<<<<<<<<< @@ -6936,35 +7017,35 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p */ __pyx_v_a_ = (&__pyx_v_self->rule->get()->a_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":132 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":139 * 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 = 132; __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 = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_a_->resize(__pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":135 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":142 * 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 = 135; __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 = 142; __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":136 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":143 * 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 = 136; __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 = 143; __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; @@ -6976,7 +7057,7 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p 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;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -6989,14 +7070,14 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p __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;} + __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 143; __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 = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } 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 = 136; __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 = 143; __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; @@ -7004,7 +7085,7 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p __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 = 136; __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 = 143; __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; @@ -7012,17 +7093,17 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __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_filename = __pyx_f[2]; __pyx_lineno = 143; __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 = 136; __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 = 143; __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 = 136; __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 = 143; __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":137 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":144 * for i in range(len(a)): * s, t = a[i] * a_[0][i] = grammar.AlignmentPoint(s, t) # <<<<<<<<<<<<<< @@ -7057,7 +7138,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_6scores_1__get__(PyObject *__pyx_v_self) return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":140 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":147 * * property scores: * def __get__(self): # <<<<<<<<<<<<<< @@ -7075,20 +7156,20 @@ static PyObject *__pyx_pf_5_cdec_5TRule_6scores___get__(struct __pyx_obj_5_cdec_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":141 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":148 * property scores: * def __get__(self): * cdef SparseVector scores = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * scores.vector = new FastSparseVector[double](self.rule.get().scores_) * return scores */ - __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_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 148; __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;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 148; __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":142 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":149 * def __get__(self): * cdef SparseVector scores = SparseVector.__new__(SparseVector) * scores.vector = new FastSparseVector[double](self.rule.get().scores_) # <<<<<<<<<<<<<< @@ -7097,7 +7178,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_6scores___get__(struct __pyx_obj_5_cdec_ */ __pyx_v_scores->vector = new FastSparseVector<double>(__pyx_v_self->rule->get()->scores_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":143 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":150 * cdef SparseVector scores = SparseVector.__new__(SparseVector) * scores.vector = new FastSparseVector[double](self.rule.get().scores_) * return scores # <<<<<<<<<<<<<< @@ -7133,7 +7214,7 @@ static int __pyx_pw_5_cdec_5TRule_6scores_3__set__(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":145 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":152 * return scores * * def __set__(self, scores): # <<<<<<<<<<<<<< @@ -7146,6 +7227,7 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule int __pyx_v_fid; float __pyx_v_fval; PyObject *__pyx_v_fname = NULL; + PyObject *__pyx_v_fn = NULL; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -7157,13 +7239,14 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule PyObject *__pyx_t_7 = NULL; PyObject *(*__pyx_t_8)(PyObject *); float __pyx_t_9; - int __pyx_t_10; + char *__pyx_t_10; + int __pyx_t_11; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":146 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":153 * * def __set__(self, scores): * cdef FastSparseVector[double]* scores_ = &self.rule.get().scores_ # <<<<<<<<<<<<<< @@ -7172,7 +7255,7 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_scores_ = (&__pyx_v_self->rule->get()->scores_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":147 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":154 * def __set__(self, scores): * cdef FastSparseVector[double]* scores_ = &self.rule.get().scores_ * scores_.clear() # <<<<<<<<<<<<<< @@ -7181,23 +7264,23 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_scores_->clear(); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":150 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":157 * cdef int fid * cdef float fval * for fname, fval in scores.items(): # <<<<<<<<<<<<<< - * fid = FDConvert(<char *>as_str(fname)) - * if fid < 0: raise KeyError(fname) + * fn = as_str(fname) + * fid = FDConvert(fn) */ - __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_t_1 = PyObject_GetAttr(__pyx_v_scores, __pyx_n_s__items); 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_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_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); 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); __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 = 150; __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 = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; } @@ -7206,23 +7289,23 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule 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++; + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 157; __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++; + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 157; __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 = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -7238,7 +7321,7 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule 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;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -7251,14 +7334,14 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule __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;} + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __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 = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } 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 = 150; __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 = 157; __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; @@ -7266,7 +7349,7 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule __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 = 150; __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 = 157; __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; @@ -7274,51 +7357,65 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __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_filename = __pyx_f[2]; __pyx_lineno = 157; __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 = 150; __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 = 157; __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":151 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":158 * cdef float fval * for fname, fval in scores.items(): - * fid = FDConvert(<char *>as_str(fname)) # <<<<<<<<<<<<<< + * fn = as_str(fname) # <<<<<<<<<<<<<< + * fid = FDConvert(fn) * if fid < 0: raise KeyError(fname) - * scores_.set_value(fid, fval) */ - __pyx_v_fid = FD::Convert(((char *)__pyx_f_5_cdec_as_str(__pyx_v_fname, NULL))); + __pyx_t_2 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_v_fname, NULL)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XDECREF(((PyObject *)__pyx_v_fn)); + __pyx_v_fn = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":152 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":159 * for fname, fval in scores.items(): - * fid = FDConvert(<char *>as_str(fname)) + * fn = as_str(fname) + * fid = FDConvert(fn) # <<<<<<<<<<<<<< + * if fid < 0: raise KeyError(fname) + * scores_.set_value(fid, fval) + */ + __pyx_t_10 = PyBytes_AsString(((PyObject *)__pyx_v_fn)); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_fid = FD::Convert(__pyx_t_10); + + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":160 + * fn = as_str(fname) + * fid = FDConvert(fn) * if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<< * scores_.set_value(fid, fval) * */ - __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 = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = (__pyx_v_fid < 0); + if (__pyx_t_11) { + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 160; __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 = 152; __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 = 160; __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 = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L7; } __pyx_L7:; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":153 - * fid = FDConvert(<char *>as_str(fname)) + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":161 + * fid = FDConvert(fn) * if fid < 0: raise KeyError(fname) * scores_.set_value(fid, fval) # <<<<<<<<<<<<<< * @@ -7340,6 +7437,7 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_fname); + __Pyx_XDECREF(__pyx_v_fn); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -7355,11 +7453,11 @@ static PyObject *__pyx_pw_5_cdec_5TRule_3lhs_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":156 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":164 * * property lhs: * def __get__(self): # <<<<<<<<<<<<<< - * return NT(TDConvert(-self.rule.get().lhs_)) + * return NT(TDConvert(-self.rule.get().lhs_).c_str()) * */ @@ -7373,22 +7471,22 @@ static PyObject *__pyx_pf_5_cdec_5TRule_3lhs___get__(struct __pyx_obj_5_cdec_TRu int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":157 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":165 * property lhs: * def __get__(self): - * return NT(TDConvert(-self.rule.get().lhs_)) # <<<<<<<<<<<<<< + * return NT(TDConvert(-self.rule.get().lhs_).c_str()) # <<<<<<<<<<<<<< * * 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 = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_self->rule->get()->lhs_)).c_str()); 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_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_t_2 = PyTuple_New(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); 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 = 157; __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 = 165; __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; @@ -7419,8 +7517,8 @@ static int __pyx_pw_5_cdec_5TRule_3lhs_3__set__(PyObject *__pyx_v_self, PyObject return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":159 - * return NT(TDConvert(-self.rule.get().lhs_)) +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":167 + * return NT(TDConvert(-self.rule.get().lhs_).c_str()) * * def __set__(self, lhs): # <<<<<<<<<<<<<< * if not isinstance(lhs, NT): @@ -7441,12 +7539,12 @@ static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *_ __Pyx_RefNannySetupContext("__set__", 0); __Pyx_INCREF(__pyx_v_lhs); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":160 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":168 * * def __set__(self, lhs): * if not isinstance(lhs, NT): # <<<<<<<<<<<<<< * lhs = NT(lhs) - * self.rule.get().lhs_ = -TDConvert(<char *>lhs.cat) + * self.rule.get().lhs_ = -TDConvert((<NT> lhs).cat) */ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)); __Pyx_INCREF(__pyx_t_1); @@ -7455,19 +7553,19 @@ static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *_ __pyx_t_3 = (!__pyx_t_2); if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":161 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":169 * def __set__(self, lhs): * if not isinstance(lhs, NT): * lhs = NT(lhs) # <<<<<<<<<<<<<< - * self.rule.get().lhs_ = -TDConvert(<char *>lhs.cat) + * self.rule.get().lhs_ = -TDConvert((<NT> lhs).cat) * */ - __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_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __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 = 161; __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 = 169; __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); @@ -7477,18 +7575,15 @@ static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *_ } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":162 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":170 * if not isinstance(lhs, NT): * lhs = NT(lhs) - * self.rule.get().lhs_ = -TDConvert(<char *>lhs.cat) # <<<<<<<<<<<<<< + * self.rule.get().lhs_ = -TDConvert((<NT> 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 = 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 = 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))); + __pyx_t_5 = PyBytes_AsString(((PyObject *)((struct __pyx_obj_5_cdec_NT *)__pyx_v_lhs)->cat)); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->rule->get()->lhs_ = (-TD::Convert(__pyx_t_5)); __pyx_r = 0; goto __pyx_L0; @@ -7513,9 +7608,9 @@ static PyObject *__pyx_pw_5_cdec_5TRule_5__str__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator18(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator19(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":165 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":173 * * def __str__(self): * scores = ' '.join('%s=%s' % feat for feat in self.scores) # <<<<<<<<<<<<<< @@ -7541,7 +7636,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_7__str___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_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_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_5TRule_7__str___2generator19, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -7559,7 +7654,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_7__str___genexpr(PyObject *__pyx_self) { return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator18(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator19(__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; @@ -7577,15 +7672,15 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator18(__pyx_GeneratorObj return NULL; } __pyx_L3_first_run:; - 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;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __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 = 173; __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 = 173; __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 = 165; __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 = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; } @@ -7594,23 +7689,23 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator18(__pyx_GeneratorObj 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++; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 173; __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++; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 173; __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 = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -7621,7 +7716,7 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator18(__pyx_GeneratorObj __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 = 165; __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 = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_r = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; @@ -7640,7 +7735,7 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator18(__pyx_GeneratorObj __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 = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetNone(PyExc_StopIteration); @@ -7657,8 +7752,8 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator18(__pyx_GeneratorObj return NULL; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":164 - * self.rule.get().lhs_ = -TDConvert(<char *>lhs.cat) +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":172 + * self.rule.get().lhs_ = -TDConvert((<NT> lhs).cat) * * def __str__(self): # <<<<<<<<<<<<<< * scores = ' '.join('%s=%s' % feat for feat in self.scores) @@ -7689,30 +7784,30 @@ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule * __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":165 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":173 * * 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 = 165; __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 = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __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_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 = 173; __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 = 165; __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 = 173; __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 = 165; __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 = 173; __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":166 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":174 * def __str__(self): * scores = ' '.join('%s=%s' % feat for feat in self.scores) * return '%s ||| %s ||| %s ||| %s' % (self.lhs, # <<<<<<<<<<<<<< @@ -7720,43 +7815,43 @@ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule * * */ __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 = 166; __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 = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":167 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":175 * 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 MRule(TRule): */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __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 = 167; __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 = 175; __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 = 167; __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 = 175; __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 = 167; __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 = 175; __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 = 167; __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 = 175; __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 = 167; __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 = 175; __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 = 167; __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 = 175; __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 = 167; __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 = 175; __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 = 166; __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 = 174; __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); @@ -7770,7 +7865,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule * __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 = 166; __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 = 174; __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); @@ -7797,31 +7892,24 @@ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule * /* Python wrapper */ static int __pyx_pw_5_cdec_5MRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_5MRule___init__[] = "MRule(lhs, rhs, scores, a=None) -> Monolingual rule.\n lhs: left hand side non-terminal\n rhs: right hand side phrase (list of words/NT)\n scores: dictionary of feature scores"; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_5MRule___init__; +#endif static int __pyx_pw_5_cdec_5MRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_lhs = 0; PyObject *__pyx_v_rhs = 0; PyObject *__pyx_v_scores = 0; - PyObject *__pyx_v_a = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__lhs,&__pyx_n_s__rhs,&__pyx_n_s__scores,&__pyx_n_s__a,0}; - PyObject* values[4] = {0,0,0,0}; - - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":170 - * - * cdef class MRule(TRule): - * def __init__(self, lhs, rhs, scores, a=None): # <<<<<<<<<<<<<< - * cdef unsigned i = 1 - * e = [] - */ - values[3] = ((PyObject *)Py_None); + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__lhs,&__pyx_n_s__rhs,&__pyx_n_s__scores,0}; + PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); @@ -7836,51 +7924,50 @@ static int __pyx_pw_5_cdec_5MRule_1__init__(PyObject *__pyx_v_self, PyObject *__ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__rhs)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scores)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 3: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__a); - if (value) { values[3] = value; kw_args--; } + __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L3_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 = 170; __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 = 178; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_lhs = values[0]; __pyx_v_rhs = values[1]; __pyx_v_scores = values[2]; - __pyx_v_a = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.MRule.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_cdec_5MRule___init__(((struct __pyx_obj_5_cdec_MRule *)__pyx_v_self), __pyx_v_lhs, __pyx_v_rhs, __pyx_v_scores, __pyx_v_a); + __pyx_r = __pyx_pf_5_cdec_5MRule___init__(((struct __pyx_obj_5_cdec_MRule *)__pyx_v_self), __pyx_v_lhs, __pyx_v_rhs, __pyx_v_scores); __Pyx_RefNannyFinishContext(); return __pyx_r; } -static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_rhs, PyObject *__pyx_v_scores, PyObject *__pyx_v_a) { +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":178 + * + * cdef class MRule(TRule): + * def __init__(self, lhs, rhs, scores): # <<<<<<<<<<<<<< + * """MRule(lhs, rhs, scores, a=None) -> Monolingual rule. + * lhs: left hand side non-terminal + */ + +static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_rhs, PyObject *__pyx_v_scores) { unsigned int __pyx_v_i; PyObject *__pyx_v_e = NULL; PyObject *__pyx_v_s = NULL; @@ -7898,28 +7985,28 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":171 - * cdef class MRule(TRule): - * def __init__(self, lhs, rhs, scores, a=None): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":183 + * rhs: right hand side phrase (list of words/NT) + * scores: dictionary of feature scores""" * cdef unsigned i = 1 # <<<<<<<<<<<<<< * e = [] * for s in rhs: */ __pyx_v_i = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":172 - * def __init__(self, lhs, rhs, scores, a=None): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":184 + * scores: dictionary of feature scores""" * cdef unsigned i = 1 * e = [] # <<<<<<<<<<<<<< * for s in rhs: * if isinstance(s, NT): */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_e = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":173 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":185 * cdef unsigned i = 1 * e = [] * for s in rhs: # <<<<<<<<<<<<<< @@ -7930,7 +8017,7 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __pyx_t_1 = __pyx_v_rhs; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; } @@ -7938,23 +8025,23 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ 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++; + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __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 = 185; __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++; + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __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 = 185; __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 = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -7964,7 +8051,7 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __pyx_v_s = __pyx_t_4; __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":174 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":186 * e = [] * for s in rhs: * if isinstance(s, NT): # <<<<<<<<<<<<<< @@ -7977,27 +8064,27 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":175 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":187 * for s in rhs: * if isinstance(s, NT): * e.append(NTRef(i)) # <<<<<<<<<<<<<< * i += 1 * else: */ - __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":176 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":188 * if isinstance(s, NT): * e.append(NTRef(i)) * i += 1 # <<<<<<<<<<<<<< @@ -8009,27 +8096,27 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":178 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":190 * i += 1 * else: * e.append(s) # <<<<<<<<<<<<<< - * super(MRule, self).__init__(lhs, rhs, e, scores, a) + * super(MRule, self).__init__(lhs, rhs, e, scores, None) * */ - __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_v_s); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_v_s); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L5:; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":179 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":191 * else: * e.append(s) - * super(MRule, self).__init__(lhs, rhs, e, scores, a) # <<<<<<<<<<<<<< + * super(MRule, self).__init__(lhs, rhs, e, scores, None) # <<<<<<<<<<<<<< * * cdef class Grammar: */ - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_MRule))); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_MRule))); @@ -8037,13 +8124,13 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_4 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_lhs); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_lhs); @@ -8057,10 +8144,10 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __Pyx_INCREF(__pyx_v_scores); PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_scores); __Pyx_GIVEREF(__pyx_v_scores); - __Pyx_INCREF(__pyx_v_a); - PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_v_a); - __Pyx_GIVEREF(__pyx_v_a); - __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_t_4, 4, Py_None); + __Pyx_GIVEREF(Py_None); + __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; @@ -8090,7 +8177,7 @@ static void __pyx_pw_5_cdec_7Grammar_1__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":184 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":196 * cdef shared_ptr[grammar.Grammar]* grammar * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -8102,7 +8189,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":185 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":197 * * def __dealloc__(self): * del self.grammar # <<<<<<<<<<<<<< @@ -8126,7 +8213,7 @@ static PyObject *__pyx_pw_5_cdec_7Grammar_3__iter__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":187 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":199 * del self.grammar * * def __iter__(self): # <<<<<<<<<<<<<< @@ -8152,7 +8239,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 = 187; __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 = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -8187,9 +8274,9 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":188 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":200 * * def __iter__(self): * cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot() # <<<<<<<<<<<<<< @@ -8198,7 +8285,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p */ __pyx_cur_scope->__pyx_v_root = __pyx_cur_scope->__pyx_v_self->grammar->get()->GetRoot(); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":189 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":201 * def __iter__(self): * cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot() * cdef grammar.const_RuleBin* rbin = root.GetRules() # <<<<<<<<<<<<<< @@ -8207,7 +8294,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p */ __pyx_cur_scope->__pyx_v_rbin = __pyx_cur_scope->__pyx_v_root->GetRules(); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":192 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":204 * cdef TRule trule * cdef unsigned i * for i in range(rbin.GetNumRules()): # <<<<<<<<<<<<<< @@ -8218,23 +8305,23 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":193 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":205 * cdef unsigned i * for i in range(rbin.GetNumRules()): * trule = TRule.__new__(TRule) # <<<<<<<<<<<<<< * trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i)) * yield trule */ - __pyx_t_3 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_TRule)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 193; __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 = 205; __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 = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __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":194 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":206 * for i in range(rbin.GetNumRules()): * trule = TRule.__new__(TRule) * trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i)) # <<<<<<<<<<<<<< @@ -8243,7 +8330,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p */ __pyx_cur_scope->__pyx_v_trule->rule = new boost::shared_ptr<TRule>(__pyx_cur_scope->__pyx_v_rbin->GetIthRule(__pyx_cur_scope->__pyx_v_i)); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":195 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":207 * trule = TRule.__new__(TRule) * trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i)) * yield trule # <<<<<<<<<<<<<< @@ -8262,7 +8349,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 = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -8288,29 +8375,51 @@ 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":198 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":210 * * property name: * def __get__(self): # <<<<<<<<<<<<<< - * self.grammar.get().GetGrammarName().c_str() + * str(self.grammar.get().GetGrammarName().c_str()) * */ static PyObject *__pyx_pf_5_cdec_7Grammar_4name___get__(struct __pyx_obj_5_cdec_Grammar *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":199 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":211 * property name: * def __get__(self): - * self.grammar.get().GetGrammarName().c_str() # <<<<<<<<<<<<<< + * str(self.grammar.get().GetGrammarName().c_str()) # <<<<<<<<<<<<<< * * def __set__(self, name): */ - __pyx_v_self->grammar->get()->GetGrammarName().c_str(); + __pyx_t_1 = PyBytes_FromString(__pyx_v_self->grammar->get()->GetGrammarName().c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 211; __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 = 211; __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*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("_cdec.Grammar.name.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; @@ -8327,50 +8436,71 @@ 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":201 - * self.grammar.get().GetGrammarName().c_str() +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":213 + * str(self.grammar.get().GetGrammarName().c_str()) * * def __set__(self, name): # <<<<<<<<<<<<<< - * self.grammar.get().SetGrammarName(string(<char *>name)) - * + * name = as_str(name) + * self.grammar.get().SetGrammarName(name) */ static int __pyx_pf_5_cdec_7Grammar_4name_2__set__(struct __pyx_obj_5_cdec_Grammar *__pyx_v_self, PyObject *__pyx_v_name) { int __pyx_r; __Pyx_RefNannyDeclarations - char *__pyx_t_1; + PyObject *__pyx_t_1 = NULL; + std::string __pyx_t_2; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); + __Pyx_INCREF(__pyx_v_name); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":202 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":214 * * def __set__(self, name): - * self.grammar.get().SetGrammarName(string(<char *>name)) # <<<<<<<<<<<<<< + * name = as_str(name) # <<<<<<<<<<<<<< + * self.grammar.get().SetGrammarName(name) + * + */ + __pyx_t_1 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_v_name, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_v_name); + __pyx_v_name = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":215 + * def __set__(self, name): + * name = as_str(name) + * self.grammar.get().SetGrammarName(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 = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->grammar->get()->SetGrammarName(std::string(((char *)__pyx_t_1))); + __pyx_t_2 = __pyx_convert_string_from_py_(__pyx_v_name); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->grammar->get()->SetGrammarName(__pyx_t_2); __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_cdec.Grammar.name.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_name); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ -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) { +static int __pyx_pw_5_cdec_11TextGrammar_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_11TextGrammar___init__[] = "TextGrammar(rules) -> SCFG Grammar containing the rules."; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_11TextGrammar___init__; +#endif +static int __pyx_pw_5_cdec_11TextGrammar_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_rules = 0; int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__rules,0}; PyObject* values[1] = {0}; @@ -8389,7 +8519,7 @@ static int __pyx_pw_5_cdec_11TextGrammar_1__cinit__(PyObject *__pyx_v_self, PyOb else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __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 = 218; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -8400,26 +8530,26 @@ 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 = 205; __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 = 218; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("_cdec.TextGrammar.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.TextGrammar.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_cdec_11TextGrammar___cinit__(((struct __pyx_obj_5_cdec_TextGrammar *)__pyx_v_self), __pyx_v_rules); + __pyx_r = __pyx_pf_5_cdec_11TextGrammar___init__(((struct __pyx_obj_5_cdec_TextGrammar *)__pyx_v_self), __pyx_v_rules); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":205 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":218 * * cdef class TextGrammar(Grammar): - * def __cinit__(self, rules): # <<<<<<<<<<<<<< + * def __init__(self, rules): # <<<<<<<<<<<<<< + * """TextGrammar(rules) -> SCFG Grammar containing the rules.""" * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) - * cdef grammar.TextGrammar* _g = <grammar.TextGrammar*> self.grammar.get() */ -static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextGrammar *__pyx_v_self, PyObject *__pyx_v_rules) { +static int __pyx_pf_5_cdec_11TextGrammar___init__(struct __pyx_obj_5_cdec_TextGrammar *__pyx_v_self, PyObject *__pyx_v_rules) { TextGrammar *__pyx_v__g; PyObject *__pyx_v_trule = NULL; int __pyx_r; @@ -8434,19 +8564,19 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__cinit__", 0); + __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":206 - * cdef class TextGrammar(Grammar): - * def __cinit__(self, rules): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":220 + * def __init__(self, rules): + * """TextGrammar(rules) -> SCFG Grammar containing the rules.""" * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) # <<<<<<<<<<<<<< * cdef grammar.TextGrammar* _g = <grammar.TextGrammar*> self.grammar.get() * for trule in rules: */ __pyx_v_self->__pyx_base.grammar = new boost::shared_ptr<Grammar>(new TextGrammar()); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":207 - * def __cinit__(self, rules): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":221 + * """TextGrammar(rules) -> SCFG Grammar containing the rules.""" * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) * cdef grammar.TextGrammar* _g = <grammar.TextGrammar*> self.grammar.get() # <<<<<<<<<<<<<< * for trule in rules: @@ -8454,7 +8584,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG */ __pyx_v__g = ((TextGrammar *)__pyx_v_self->__pyx_base.grammar->get()); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":208 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":222 * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) * cdef grammar.TextGrammar* _g = <grammar.TextGrammar*> self.grammar.get() * for trule in rules: # <<<<<<<<<<<<<< @@ -8465,7 +8595,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG __pyx_t_1 = __pyx_v_rules; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rules); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 208; __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 = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; } @@ -8473,23 +8603,23 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG 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++; + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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 = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __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++; + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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 = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __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 = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -8499,7 +8629,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG __pyx_v_trule = __pyx_t_4; __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":209 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":223 * cdef grammar.TextGrammar* _g = <grammar.TextGrammar*> self.grammar.get() * for trule in rules: * if isinstance(trule, _sa.Rule): # <<<<<<<<<<<<<< @@ -8512,17 +8642,17 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":210 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":224 * for trule in rules: * if isinstance(trule, _sa.Rule): * trule = convert_rule(trule) # <<<<<<<<<<<<<< * elif not isinstance(trule, TRule): * raise ValueError('the grammar should contain TRule objects') */ - if (!(likely(((__pyx_v_trule) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_trule, __pyx_ptype_4cdec_2sa_3_sa_Rule))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_v_trule) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_trule, __pyx_ptype_4cdec_2sa_3_sa_Rule))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 224; __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 = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = ((PyObject *)__pyx_f_5_cdec_convert_rule(((struct __pyx_obj_4cdec_2sa_3_sa_Rule *)__pyx_t_4))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_v_trule); @@ -8531,7 +8661,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG goto __pyx_L5; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":211 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":225 * if isinstance(trule, _sa.Rule): * trule = convert_rule(trule) * elif not isinstance(trule, TRule): # <<<<<<<<<<<<<< @@ -8545,22 +8675,22 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG __pyx_t_7 = (!__pyx_t_5); if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":212 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":226 * 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 = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 226; __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 = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L5; } __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":213 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":227 * elif not isinstance(trule, TRule): * raise ValueError('the grammar should contain TRule objects') * _g.AddRule((<TRule> trule).rule[0]) # <<<<<<<<<<<<<< @@ -8575,7 +8705,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG __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_AddTraceback("_cdec.TextGrammar.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_trule); @@ -8592,7 +8722,7 @@ static void __pyx_pw_5_cdec_10Hypergraph_1__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":8 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":8 * cdef MT19937* rng * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -8605,7 +8735,7 @@ static void __pyx_pf_5_cdec_10Hypergraph___dealloc__(struct __pyx_obj_5_cdec_Hyp int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":9 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":9 * * def __dealloc__(self): * del self.hg # <<<<<<<<<<<<<< @@ -8614,7 +8744,7 @@ static void __pyx_pf_5_cdec_10Hypergraph___dealloc__(struct __pyx_obj_5_cdec_Hyp */ delete __pyx_v_self->hg; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":10 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":10 * def __dealloc__(self): * del self.hg * if self.rng != NULL: # <<<<<<<<<<<<<< @@ -8624,12 +8754,12 @@ static void __pyx_pf_5_cdec_10Hypergraph___dealloc__(struct __pyx_obj_5_cdec_Hyp __pyx_t_1 = (__pyx_v_self->rng != NULL); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":11 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":11 * del self.hg * if self.rng != NULL: * del self.rng # <<<<<<<<<<<<<< * - * def viterbi(self): + * cdef MT19937* _rng(self): */ delete __pyx_v_self->rng; goto __pyx_L3; @@ -8639,8 +8769,70 @@ static void __pyx_pf_5_cdec_10Hypergraph___dealloc__(struct __pyx_obj_5_cdec_Hyp __Pyx_RefNannyFinishContext(); } +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":13 + * del self.rng + * + * cdef MT19937* _rng(self): # <<<<<<<<<<<<<< + * if self.rng == NULL: + * self.rng = new MT19937() + */ + +static MT19937 *__pyx_f_5_cdec_10Hypergraph__rng(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { + MT19937 *__pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + MT19937 *__pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_rng", 0); + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":14 + * + * cdef MT19937* _rng(self): + * if self.rng == NULL: # <<<<<<<<<<<<<< + * self.rng = new MT19937() + * return self.rng + */ + __pyx_t_1 = (__pyx_v_self->rng == NULL); + if (__pyx_t_1) { + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":15 + * cdef MT19937* _rng(self): + * if self.rng == NULL: + * self.rng = new MT19937() # <<<<<<<<<<<<<< + * return self.rng + * + */ + try {__pyx_t_2 = new MT19937();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_v_self->rng = __pyx_t_2; + goto __pyx_L3; + } + __pyx_L3:; + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":16 + * if self.rng == NULL: + * self.rng = new MT19937() + * return self.rng # <<<<<<<<<<<<<< + * + * def viterbi(self): + */ + __pyx_r = __pyx_v_self->rng; + goto __pyx_L0; + + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_WriteUnraisable("_cdec.Hypergraph._rng", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_3viterbi(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_2viterbi[] = "hg.viterbi() -> String for the best hypothesis in the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_3viterbi(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -8650,12 +8842,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_3viterbi(PyObject *__pyx_v_self, C return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":13 - * del self.rng +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":18 + * return self.rng * * def viterbi(self): # <<<<<<<<<<<<<< + * """hg.viterbi() -> String for the best hypothesis in the hypergraph.""" * cdef vector[WordID] trans - * hypergraph.ViterbiESentence(self.hg[0], &trans) */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { @@ -8669,8 +8861,8 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_H int __pyx_clineno = 0; __Pyx_RefNannySetupContext("viterbi", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":15 - * def viterbi(self): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":21 + * """hg.viterbi() -> String for the best hypothesis in the hypergraph.""" * cdef vector[WordID] trans * hypergraph.ViterbiESentence(self.hg[0], &trans) # <<<<<<<<<<<<<< * return unicode(GetString(trans).c_str(), 'utf8') @@ -8678,7 +8870,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_H */ ViterbiESentence((__pyx_v_self->hg[0]), (&__pyx_v_trans)); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":16 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":22 * cdef vector[WordID] trans * hypergraph.ViterbiESentence(self.hg[0], &trans) * return unicode(GetString(trans).c_str(), 'utf8') # <<<<<<<<<<<<<< @@ -8686,9 +8878,9 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_H * def viterbi_trees(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(TD::GetString(__pyx_v_trans).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(TD::GetString(__pyx_v_trans).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 22; __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)); @@ -8696,7 +8888,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_H PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 22; __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; @@ -8718,6 +8910,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_H /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_5viterbi_trees(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_4viterbi_trees[] = "hg.viterbi_trees() -> (f_tree, e_tree)\n f_tree: Source tree for the best hypothesis in the hypergraph.\n e_tree: Target tree for the best hypothesis in the hypergraph.\n "; static PyObject *__pyx_pw_5_cdec_10Hypergraph_5viterbi_trees(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -8727,12 +8920,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_5viterbi_trees(PyObject *__pyx_v_s return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":18 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":24 * return unicode(GetString(trans).c_str(), 'utf8') * * def viterbi_trees(self): # <<<<<<<<<<<<<< - * f_tree = unicode(hypergraph.ViterbiFTree(self.hg[0]).c_str(), 'utf8') - * e_tree = unicode(hypergraph.ViterbiETree(self.hg[0]).c_str(), 'utf8') + * """hg.viterbi_trees() -> (f_tree, e_tree) + * f_tree: Source tree for the best hypothesis in the hypergraph. */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { @@ -8747,16 +8940,16 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("viterbi_trees", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":19 - * - * def viterbi_trees(self): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":29 + * e_tree: Target tree for the best hypothesis in the hypergraph. + * """ * f_tree = unicode(hypergraph.ViterbiFTree(self.hg[0]).c_str(), 'utf8') # <<<<<<<<<<<<<< * e_tree = unicode(hypergraph.ViterbiETree(self.hg[0]).c_str(), 'utf8') * return (f_tree, e_tree) */ - __pyx_t_1 = PyBytes_FromString(ViterbiFTree((__pyx_v_self->hg[0])).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(ViterbiFTree((__pyx_v_self->hg[0])).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; __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)); @@ -8764,22 +8957,22 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_ PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_v_f_tree = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":20 - * def viterbi_trees(self): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":30 + * """ * f_tree = unicode(hypergraph.ViterbiFTree(self.hg[0]).c_str(), 'utf8') * e_tree = unicode(hypergraph.ViterbiETree(self.hg[0]).c_str(), 'utf8') # <<<<<<<<<<<<<< * return (f_tree, e_tree) * */ - __pyx_t_1 = PyBytes_FromString(ViterbiETree((__pyx_v_self->hg[0])).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(ViterbiETree((__pyx_v_self->hg[0])).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 30; __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)); @@ -8787,13 +8980,13 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_ PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_v_e_tree = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":21 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":31 * f_tree = unicode(hypergraph.ViterbiFTree(self.hg[0]).c_str(), 'utf8') * e_tree = unicode(hypergraph.ViterbiETree(self.hg[0]).c_str(), 'utf8') * return (f_tree, e_tree) # <<<<<<<<<<<<<< @@ -8801,7 +8994,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_ * def viterbi_features(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_f_tree)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_f_tree)); @@ -8830,6 +9023,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_7viterbi_features(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_6viterbi_features[] = "hg.viterbi_features() -> SparseVector with the features corresponding\n to the best derivation in the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_7viterbi_features(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -8839,12 +9033,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_7viterbi_features(PyObject *__pyx_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":23 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":33 * return (f_tree, e_tree) * * def viterbi_features(self): # <<<<<<<<<<<<<< - * cdef SparseVector fmap = SparseVector.__new__(SparseVector) - * fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0])) + * """hg.viterbi_features() -> SparseVector with the features corresponding + * to the best derivation in the hypergraph.""" */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6viterbi_features(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { @@ -8857,21 +9051,21 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6viterbi_features(struct __pyx_obj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("viterbi_features", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":24 - * - * def viterbi_features(self): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":36 + * """hg.viterbi_features() -> SparseVector with the features corresponding + * to the best derivation in the hypergraph.""" * cdef SparseVector fmap = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0])) * return fmap */ - __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_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 36; __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;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 36; __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): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":37 + * to the best derivation in the hypergraph.""" * cdef SparseVector fmap = SparseVector.__new__(SparseVector) * fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0])) # <<<<<<<<<<<<<< * return fmap @@ -8879,7 +9073,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 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":38 * cdef SparseVector fmap = SparseVector.__new__(SparseVector) * fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0])) * return fmap # <<<<<<<<<<<<<< @@ -8906,6 +9100,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6viterbi_features(struct __pyx_obj /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_9viterbi_joshua(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_8viterbi_joshua[] = "hg.viterbi_joshua() -> Joshua representation of the best derivation."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_9viterbi_joshua(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -8915,12 +9110,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_9viterbi_joshua(PyObject *__pyx_v_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":28 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":40 * return fmap * * def viterbi_joshua(self): # <<<<<<<<<<<<<< + * """hg.viterbi_joshua() -> Joshua representation of the best derivation.""" * return unicode(hypergraph.JoshuaVisualizationString(self.hg[0]).c_str(), 'utf8') - * */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_8viterbi_joshua(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { @@ -8933,17 +9128,17 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_8viterbi_joshua(struct __pyx_obj_5 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("viterbi_joshua", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":29 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":42 * def viterbi_joshua(self): + * """hg.viterbi_joshua() -> Joshua representation of the best derivation.""" * return unicode(hypergraph.JoshuaVisualizationString(self.hg[0]).c_str(), 'utf8') # <<<<<<<<<<<<<< * * def kbest(self, size): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(JoshuaVisualizationString((__pyx_v_self->hg[0])).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(JoshuaVisualizationString((__pyx_v_self->hg[0])).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 42; __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)); @@ -8951,7 +9146,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_8viterbi_joshua(struct __pyx_obj_5 PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 42; __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; @@ -8974,6 +9169,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_11kbest(PyObject *__pyx_v_self, PyObject *__pyx_v_size); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_10kbest[] = "hg.kbest(size) -> List of k-best hypotheses in the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_11kbest(PyObject *__pyx_v_self, PyObject *__pyx_v_size) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -8983,12 +9179,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_11kbest(PyObject *__pyx_v_self, Py return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":31 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":44 * return unicode(hypergraph.JoshuaVisualizationString(self.hg[0]).c_str(), 'utf8') * * def kbest(self, size): # <<<<<<<<<<<<<< + * """hg.kbest(size) -> List of k-best hypotheses in the hypergraph.""" * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal]* derivations = new kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal](self.hg[0], size) - * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal].Derivation* derivation */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_10kbest(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size) { @@ -9012,7 +9208,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_10kbest(struct __pyx_obj_5_cdec_Hy __Pyx_INCREF(__pyx_cur_scope->__pyx_v_size); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_size); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_12generator4, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_12generator4, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -9049,19 +9245,19 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":32 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":46 * def kbest(self, size): + * """hg.kbest(size) -> List of k-best hypotheses in the hypergraph.""" * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal]* derivations = new kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal](self.hg[0], size) # <<<<<<<<<<<<<< * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal].Derivation* derivation * cdef unsigned k */ - __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_cur_scope->__pyx_v_derivations = new KBest::KBestDerivations<std::vector<WordID>,ESentenceTraversal>((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":35 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":49 * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal].Derivation* derivation * cdef unsigned k * try: # <<<<<<<<<<<<<< @@ -9070,18 +9266,18 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject */ /*try:*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":36 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":50 * cdef unsigned k * try: * for k in range(size): # <<<<<<<<<<<<<< * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not derivation: break */ - __pyx_t_2 = __Pyx_PyInt_AsLong(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_2 = __Pyx_PyInt_AsLong(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L5;} for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_2; __pyx_t_1+=1) { __pyx_cur_scope->__pyx_v_k = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":37 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":51 * try: * for k in range(size): * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) # <<<<<<<<<<<<<< @@ -9090,7 +9286,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject */ __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); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":38 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":52 * for k in range(size): * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not derivation: break # <<<<<<<<<<<<<< @@ -9104,16 +9300,16 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject } __pyx_L9:; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":39 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":53 * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not derivation: break * yield unicode(GetString(derivation._yield).c_str(), 'utf8') # <<<<<<<<<<<<<< * finally: * del derivations */ - __pyx_t_4 = PyBytes_FromString(TD::GetString(__pyx_cur_scope->__pyx_v_derivation->yield).c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_4 = PyBytes_FromString(TD::GetString(__pyx_cur_scope->__pyx_v_derivation->yield).c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4)); __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); @@ -9121,7 +9317,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject PyTuple_SET_ITEM(__pyx_t_5, 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 = 39; __pyx_clineno = __LINE__; goto __pyx_L5;} + __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 = 53; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; __pyx_r = __pyx_t_4; @@ -9136,12 +9332,12 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject __pyx_L10_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[3]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L5;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L5;} } __pyx_L8_break:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":41 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":55 * yield unicode(GetString(derivation._yield).c_str(), 'utf8') * finally: * del derivations # <<<<<<<<<<<<<< @@ -9192,6 +9388,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_14kbest_trees(PyObject *__pyx_v_self, PyObject *__pyx_v_size); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_13kbest_trees[] = "hg.kbest_trees(size) -> List of k-best trees in the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_14kbest_trees(PyObject *__pyx_v_self, PyObject *__pyx_v_size) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -9201,12 +9398,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_14kbest_trees(PyObject *__pyx_v_se return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":43 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":57 * del derivations * * def kbest_trees(self, size): # <<<<<<<<<<<<<< + * """hg.kbest_trees(size) -> List of k-best trees in the hypergraph.""" * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal]* f_derivations = new kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal](self.hg[0], size) - * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal].Derivation* f_derivation */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_13kbest_trees(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size) { @@ -9230,7 +9427,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_13kbest_trees(struct __pyx_obj_5_c __Pyx_INCREF(__pyx_cur_scope->__pyx_v_size); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_size); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_15generator5, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_15generator5, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -9269,29 +9466,29 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":44 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":59 * def kbest_trees(self, size): + * """hg.kbest_trees(size) -> List of k-best trees in the hypergraph.""" * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal]* f_derivations = new kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal](self.hg[0], size) # <<<<<<<<<<<<<< * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal].Derivation* f_derivation * cdef kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal]* e_derivations = new kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal](self.hg[0], size) */ - __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_cur_scope->__pyx_v_f_derivations = new KBest::KBestDerivations<std::vector<WordID>,FTreeTraversal>((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":46 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":61 * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal]* f_derivations = new kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal](self.hg[0], size) * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal].Derivation* f_derivation * cdef kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal]* e_derivations = new kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal](self.hg[0], size) # <<<<<<<<<<<<<< * cdef kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal].Derivation* e_derivation * cdef unsigned k */ - __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_cur_scope->__pyx_v_e_derivations = new KBest::KBestDerivations<std::vector<WordID>,ETreeTraversal>((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":49 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":64 * cdef kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal].Derivation* e_derivation * cdef unsigned k * try: # <<<<<<<<<<<<<< @@ -9300,18 +9497,18 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject */ /*try:*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":50 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":65 * cdef unsigned k * try: * for k in range(size): # <<<<<<<<<<<<<< * f_derivation = f_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * e_derivation = e_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) */ - __pyx_t_2 = __Pyx_PyInt_AsLong(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_2 = __Pyx_PyInt_AsLong(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L5;} for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_2; __pyx_t_1+=1) { __pyx_cur_scope->__pyx_v_k = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":51 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":66 * try: * for k in range(size): * f_derivation = f_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) # <<<<<<<<<<<<<< @@ -9320,7 +9517,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject */ __pyx_cur_scope->__pyx_v_f_derivation = __pyx_cur_scope->__pyx_v_f_derivations->LazyKthBest((__pyx_cur_scope->__pyx_v_self->hg->nodes_.size() - 1), __pyx_cur_scope->__pyx_v_k); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":52 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":67 * for k in range(size): * f_derivation = f_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * e_derivation = e_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) # <<<<<<<<<<<<<< @@ -9329,7 +9526,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject */ __pyx_cur_scope->__pyx_v_e_derivation = __pyx_cur_scope->__pyx_v_e_derivations->LazyKthBest((__pyx_cur_scope->__pyx_v_self->hg->nodes_.size() - 1), __pyx_cur_scope->__pyx_v_k); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":53 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":68 * f_derivation = f_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * e_derivation = e_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not f_derivation or not e_derivation: break # <<<<<<<<<<<<<< @@ -9349,16 +9546,16 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject } __pyx_L9:; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":54 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":69 * e_derivation = e_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not f_derivation or not e_derivation: break * f_tree = unicode(GetString(f_derivation._yield).c_str(), 'utf8') # <<<<<<<<<<<<<< * e_tree = unicode(GetString(e_derivation._yield).c_str(), 'utf8') * yield (f_tree, e_tree) */ - __pyx_t_6 = PyBytes_FromString(TD::GetString(__pyx_cur_scope->__pyx_v_f_derivation->yield).c_str()); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_6 = PyBytes_FromString(TD::GetString(__pyx_cur_scope->__pyx_v_f_derivation->yield).c_str()); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(((PyObject *)__pyx_t_6)); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_6)); __Pyx_GIVEREF(((PyObject *)__pyx_t_6)); @@ -9366,7 +9563,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_f_tree)); @@ -9375,16 +9572,16 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject __pyx_cur_scope->__pyx_v_f_tree = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":55 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":70 * if not f_derivation or not e_derivation: break * f_tree = unicode(GetString(f_derivation._yield).c_str(), 'utf8') * e_tree = unicode(GetString(e_derivation._yield).c_str(), 'utf8') # <<<<<<<<<<<<<< * yield (f_tree, e_tree) * finally: */ - __pyx_t_6 = PyBytes_FromString(TD::GetString(__pyx_cur_scope->__pyx_v_e_derivation->yield).c_str()); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_6 = PyBytes_FromString(TD::GetString(__pyx_cur_scope->__pyx_v_e_derivation->yield).c_str()); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(((PyObject *)__pyx_t_6)); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_6)); __Pyx_GIVEREF(((PyObject *)__pyx_t_6)); @@ -9392,7 +9589,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_e_tree)); @@ -9401,14 +9598,14 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject __pyx_cur_scope->__pyx_v_e_tree = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":56 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":71 * f_tree = unicode(GetString(f_derivation._yield).c_str(), 'utf8') * e_tree = unicode(GetString(e_derivation._yield).c_str(), 'utf8') * yield (f_tree, e_tree) # <<<<<<<<<<<<<< * finally: * del f_derivations */ - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_f_tree)); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_cur_scope->__pyx_v_f_tree)); @@ -9428,12 +9625,12 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject __pyx_L10_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[3]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L5;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L5;} } __pyx_L8_break:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":58 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":73 * yield (f_tree, e_tree) * finally: * del f_derivations # <<<<<<<<<<<<<< @@ -9457,7 +9654,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject __pyx_L6:; delete __pyx_cur_scope->__pyx_v_f_derivations; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":59 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":74 * finally: * del f_derivations * del e_derivations # <<<<<<<<<<<<<< @@ -9493,6 +9690,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_17kbest_features(PyObject *__pyx_v_self, PyObject *__pyx_v_size); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_16kbest_features[] = "hg.kbest_trees(size) -> List of k-best feature vectors in the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_17kbest_features(PyObject *__pyx_v_self, PyObject *__pyx_v_size) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -9502,12 +9700,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_17kbest_features(PyObject *__pyx_v return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":61 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":76 * del e_derivations * * def kbest_features(self, size): # <<<<<<<<<<<<<< + * """hg.kbest_trees(size) -> List of k-best feature vectors in the hypergraph.""" * cdef kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal]* derivations = new kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal](self.hg[0], size) - * cdef kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal].Derivation* derivation */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_16kbest_features(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size) { @@ -9531,7 +9729,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_16kbest_features(struct __pyx_obj_ __Pyx_INCREF(__pyx_cur_scope->__pyx_v_size); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_size); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_18generator6, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_18generator6, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -9567,19 +9765,19 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":62 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":78 * def kbest_features(self, size): + * """hg.kbest_trees(size) -> List of k-best feature vectors in the hypergraph.""" * cdef kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal]* derivations = new kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal](self.hg[0], size) # <<<<<<<<<<<<<< * cdef kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal].Derivation* derivation * cdef SparseVector fmap */ - __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_cur_scope->__pyx_v_derivations = new KBest::KBestDerivations<FastSparseVector<weight_t>,FeatureVectorTraversal>((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":66 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":82 * cdef SparseVector fmap * cdef unsigned k * try: # <<<<<<<<<<<<<< @@ -9588,18 +9786,18 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject */ /*try:*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":67 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":83 * cdef unsigned k * try: * for k in range(size): # <<<<<<<<<<<<<< * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not derivation: break */ - __pyx_t_2 = __Pyx_PyInt_AsLong(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_2 = __Pyx_PyInt_AsLong(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L5;} for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_2; __pyx_t_1+=1) { __pyx_cur_scope->__pyx_v_k = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":68 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":84 * try: * for k in range(size): * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) # <<<<<<<<<<<<<< @@ -9608,7 +9806,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject */ __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); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":69 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":85 * for k in range(size): * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not derivation: break # <<<<<<<<<<<<<< @@ -9622,23 +9820,23 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject } __pyx_L9:; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":70 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":86 * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not derivation: break * fmap = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * fmap.vector = new FastSparseVector[weight_t](derivation._yield) * yield fmap */ - __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_t_4 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 86; __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;} + if (!(likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 86; __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); __pyx_cur_scope->__pyx_v_fmap = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_4); __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":71 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":87 * if not derivation: break * fmap = SparseVector.__new__(SparseVector) * fmap.vector = new FastSparseVector[weight_t](derivation._yield) # <<<<<<<<<<<<<< @@ -9647,7 +9845,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 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":88 * fmap = SparseVector.__new__(SparseVector) * fmap.vector = new FastSparseVector[weight_t](derivation._yield) * yield fmap # <<<<<<<<<<<<<< @@ -9666,12 +9864,12 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject __pyx_L10_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[3]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L5;} } __pyx_L8_break:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":74 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":90 * yield fmap * finally: * del derivations # <<<<<<<<<<<<<< @@ -9720,13 +9918,14 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_20sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_n); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_19sample[] = "hg.sample(n) -> Sample of n hypotheses from the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_20sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_n) { unsigned int __pyx_v_n; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sample (wrapper)", 0); assert(__pyx_arg_n); { - __pyx_v_n = __Pyx_PyInt_AsUnsignedInt(__pyx_arg_n); if (unlikely((__pyx_v_n == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n = __Pyx_PyInt_AsUnsignedInt(__pyx_arg_n); if (unlikely((__pyx_v_n == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -9739,12 +9938,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_20sample(PyObject *__pyx_v_self, P return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":76 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":92 * del derivations * * def sample(self, unsigned n): # <<<<<<<<<<<<<< + * """hg.sample(n) -> Sample of n hypotheses from the hypergraph.""" * cdef vector[hypergraph.Hypothesis]* hypos = new vector[hypergraph.Hypothesis]() - * if self.rng == NULL: */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_19sample(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, unsigned int __pyx_v_n) { @@ -9766,7 +9965,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_19sample(struct __pyx_obj_5_cdec_H __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __pyx_cur_scope->__pyx_v_n = __pyx_v_n; { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_21generator7, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_21generator7, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -9788,67 +9987,44 @@ 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; - MT19937 *__pyx_t_2; - size_t __pyx_t_3; - unsigned int __pyx_t_4; + std::vector<HypergraphSampler::Hypothesis> *__pyx_t_1; + size_t __pyx_t_2; + unsigned int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("None", 0); switch (__pyx_generator->resume_label) { case 0: goto __pyx_L3_first_run; - case 1: goto __pyx_L10_resume_from_yield; + case 1: goto __pyx_L9_resume_from_yield; default: /* CPython raises the right error here */ __Pyx_RefNannyFinishContext(); return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":77 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":94 * def sample(self, unsigned n): + * """hg.sample(n) -> Sample of n hypotheses from the hypergraph.""" * cdef vector[hypergraph.Hypothesis]* hypos = new vector[hypergraph.Hypothesis]() # <<<<<<<<<<<<<< - * if self.rng == NULL: - * self.rng = new MT19937() - */ - __pyx_cur_scope->__pyx_v_hypos = new std::vector<HypergraphSampler::Hypothesis>(); - - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":78 - * def sample(self, unsigned n): - * cdef vector[hypergraph.Hypothesis]* hypos = new vector[hypergraph.Hypothesis]() - * if self.rng == NULL: # <<<<<<<<<<<<<< - * self.rng = new MT19937() - * hypergraph.sample_hypotheses(self.hg[0], n, self.rng, hypos) - */ - __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->rng == NULL); - if (__pyx_t_1) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":79 - * cdef vector[hypergraph.Hypothesis]* hypos = new vector[hypergraph.Hypothesis]() - * if self.rng == NULL: - * self.rng = new MT19937() # <<<<<<<<<<<<<< - * hypergraph.sample_hypotheses(self.hg[0], n, self.rng, hypos) + * hypergraph.sample_hypotheses(self.hg[0], n, self._rng(), hypos) * cdef unsigned k */ - 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:; + try {__pyx_t_1 = new std::vector<HypergraphSampler::Hypothesis>();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_cur_scope->__pyx_v_hypos = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":80 - * if self.rng == NULL: - * self.rng = new MT19937() - * hypergraph.sample_hypotheses(self.hg[0], n, self.rng, hypos) # <<<<<<<<<<<<<< + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":95 + * """hg.sample(n) -> Sample of n hypotheses from the hypergraph.""" + * cdef vector[hypergraph.Hypothesis]* hypos = new vector[hypergraph.Hypothesis]() + * hypergraph.sample_hypotheses(self.hg[0], n, self._rng(), hypos) # <<<<<<<<<<<<<< * cdef unsigned k * try: */ - HypergraphSampler::sample_hypotheses((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_cur_scope->__pyx_v_n, __pyx_cur_scope->__pyx_v_self->rng, __pyx_cur_scope->__pyx_v_hypos); + HypergraphSampler::sample_hypotheses((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_cur_scope->__pyx_v_n, ((struct __pyx_vtabstruct_5_cdec_Hypergraph *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->_rng(__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_hypos); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":82 - * hypergraph.sample_hypotheses(self.hg[0], n, self.rng, hypos) + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":97 + * hypergraph.sample_hypotheses(self.hg[0], n, self._rng(), hypos) * cdef unsigned k * try: # <<<<<<<<<<<<<< * for k in range(hypos.size()): @@ -9856,75 +10032,75 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject */ /*try:*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":83 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":98 * cdef unsigned k * try: * for k in range(hypos.size()): # <<<<<<<<<<<<<< * yield unicode(GetString(hypos[0][k].words).c_str(), 'utf8') * finally: */ - __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; + __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; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":84 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":99 * try: * for k in range(hypos.size()): * yield unicode(GetString(hypos[0][k].words).c_str(), 'utf8') # <<<<<<<<<<<<<< * finally: * del hypos */ - __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_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 = 99; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8)); - PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_n_s__utf8)); + PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); - __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_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 = 99; __pyx_clineno = __LINE__; goto __pyx_L5;} + __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_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_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;} + __pyx_L9_resume_from_yield:; + __pyx_t_2 = __pyx_cur_scope->__pyx_t_0; + __pyx_t_3 = __pyx_cur_scope->__pyx_t_1; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L5;} } } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":86 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":101 * yield unicode(GetString(hypos[0][k].words).c_str(), 'utf8') * finally: * del hypos # <<<<<<<<<<<<<< * - * def intersect(self, Lattice lat): + * def sample_trees(self, unsigned n): */ /*finally:*/ { int __pyx_why; PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; int __pyx_exc_lineno; __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 0; goto __pyx_L7; - __pyx_L6: { + __pyx_why = 0; goto __pyx_L6; + __pyx_L5: { __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; + goto __pyx_L6; } - __pyx_L7:; + __pyx_L6:; delete __pyx_cur_scope->__pyx_v_hypos; switch (__pyx_why) { case 4: { @@ -9940,8 +10116,8 @@ 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); @@ -9950,69 +10126,365 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject __Pyx_RefNannyFinishContext(); return NULL; } +static PyObject *__pyx_gb_5_cdec_10Hypergraph_24generator8(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_23intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_lat); /*proto*/ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_23intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_lat) { +static PyObject *__pyx_pw_5_cdec_10Hypergraph_23sample_trees(PyObject *__pyx_v_self, PyObject *__pyx_arg_n); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_22sample_trees[] = "hg.sample_trees(n) -> Sample of n trees from the hypergraph."; +static PyObject *__pyx_pw_5_cdec_10Hypergraph_23sample_trees(PyObject *__pyx_v_self, PyObject *__pyx_arg_n) { + unsigned int __pyx_v_n; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("intersect (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_lat), __pyx_ptype_5_cdec_Lattice, 1, "lat", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_5_cdec_10Hypergraph_22intersect(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_lat)); + __Pyx_RefNannySetupContext("sample_trees (wrapper)", 0); + assert(__pyx_arg_n); { + __pyx_v_n = __Pyx_PyInt_AsUnsignedInt(__pyx_arg_n); if (unlikely((__pyx_v_n == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("_cdec.Hypergraph.sample_trees", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_5_cdec_10Hypergraph_22sample_trees(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((unsigned int)__pyx_v_n)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":103 + * del hypos + * + * def sample_trees(self, unsigned n): # <<<<<<<<<<<<<< + * """hg.sample_trees(n) -> Sample of n trees from the hypergraph.""" + * cdef vector[string]* trees = new vector[string]() + */ + +static PyObject *__pyx_pf_5_cdec_10Hypergraph_22sample_trees(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, unsigned int __pyx_v_n) { + struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *__pyx_cur_scope; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("sample_trees", 0); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *)__pyx_ptype_5_cdec___pyx_scope_struct_12_sample_trees->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_12_sample_trees, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_cur_scope); + __pyx_cur_scope->__pyx_v_self = __pyx_v_self; + __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + __pyx_cur_scope->__pyx_v_n = __pyx_v_n; + { + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_24generator8, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_cur_scope); + __Pyx_RefNannyFinishContext(); + return (PyObject *) gen; + } + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; + __Pyx_AddTraceback("_cdec.Hypergraph.sample_trees", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":88 - * del hypos +static PyObject *__pyx_gb_5_cdec_10Hypergraph_24generator8(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +{ + struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *)__pyx_generator->closure); + PyObject *__pyx_r = NULL; + std::vector<std::string> *__pyx_t_1; + size_t __pyx_t_2; + unsigned int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("None", 0); + switch (__pyx_generator->resume_label) { + case 0: goto __pyx_L3_first_run; + case 1: goto __pyx_L9_resume_from_yield; + default: /* CPython raises the right error here */ + __Pyx_RefNannyFinishContext(); + return NULL; + } + __pyx_L3_first_run:; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":105 + * def sample_trees(self, unsigned n): + * """hg.sample_trees(n) -> Sample of n trees from the hypergraph.""" + * cdef vector[string]* trees = new vector[string]() # <<<<<<<<<<<<<< + * hypergraph.sample_trees(self.hg[0], n, self._rng(), trees) + * cdef unsigned k + */ + try {__pyx_t_1 = new std::vector<std::string>();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_cur_scope->__pyx_v_trees = __pyx_t_1; + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":106 + * """hg.sample_trees(n) -> Sample of n trees from the hypergraph.""" + * cdef vector[string]* trees = new vector[string]() + * hypergraph.sample_trees(self.hg[0], n, self._rng(), trees) # <<<<<<<<<<<<<< + * cdef unsigned k + * try: + */ + HypergraphSampler::sample_trees((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_cur_scope->__pyx_v_n, ((struct __pyx_vtabstruct_5_cdec_Hypergraph *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->_rng(__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_trees); + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":108 + * hypergraph.sample_trees(self.hg[0], n, self._rng(), trees) + * cdef unsigned k + * try: # <<<<<<<<<<<<<< + * for k in range(trees.size()): + * yield unicode(trees[0][k].c_str(), 'utf8') + */ + /*try:*/ { + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":109 + * cdef unsigned k + * try: + * for k in range(trees.size()): # <<<<<<<<<<<<<< + * yield unicode(trees[0][k].c_str(), 'utf8') + * finally: + */ + __pyx_t_2 = __pyx_cur_scope->__pyx_v_trees->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; + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":110 + * try: + * for k in range(trees.size()): + * yield unicode(trees[0][k].c_str(), 'utf8') # <<<<<<<<<<<<<< + * finally: + * del trees + */ + __pyx_t_4 = PyBytes_FromString(((__pyx_cur_scope->__pyx_v_trees[0])[__pyx_cur_scope->__pyx_v_k]).c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8)); + PyTuple_SET_ITEM(__pyx_t_5, 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 = 110; __pyx_clineno = __LINE__; goto __pyx_L5;} + __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_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + /* return from generator, yielding value */ + __pyx_generator->resume_label = 1; + return __pyx_r; + __pyx_L9_resume_from_yield:; + __pyx_t_2 = __pyx_cur_scope->__pyx_t_0; + __pyx_t_3 = __pyx_cur_scope->__pyx_t_1; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L5;} + } + } + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":112 + * yield unicode(trees[0][k].c_str(), 'utf8') + * finally: + * del trees # <<<<<<<<<<<<<< * - * def intersect(self, Lattice lat): # <<<<<<<<<<<<<< - * return hypergraph.Intersect(lat.lattice[0], self.hg) + * def intersect(self, inp): + */ + /*finally:*/ { + int __pyx_why; + PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; + int __pyx_exc_lineno; + __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; + __pyx_why = 0; goto __pyx_L6; + __pyx_L5: { + __pyx_why = 4; + __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_L6; + } + __pyx_L6:; + delete __pyx_cur_scope->__pyx_v_trees; + switch (__pyx_why) { + case 4: { + __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); + __pyx_lineno = __pyx_exc_lineno; + __pyx_exc_type = 0; + __pyx_exc_value = 0; + __pyx_exc_tb = 0; + goto __pyx_L1_error; + } + } + } + PyErr_SetNone(PyExc_StopIteration); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("sample_trees", __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; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_5_cdec_10Hypergraph_26intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_inp); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_25intersect[] = "hg.intersect(Lattice/string): Intersect the hypergraph with the provided reference."; +static PyObject *__pyx_pw_5_cdec_10Hypergraph_26intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_inp) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("intersect (wrapper)", 0); + __pyx_r = __pyx_pf_5_cdec_10Hypergraph_25intersect(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((PyObject *)__pyx_v_inp)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":114 + * del trees * + * def intersect(self, inp): # <<<<<<<<<<<<<< + * """hg.intersect(Lattice/string): Intersect the hypergraph with the provided reference.""" + * cdef Lattice lat */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_22intersect(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, struct __pyx_obj_5_cdec_Lattice *__pyx_v_lat) { +static PyObject *__pyx_pf_5_cdec_10Hypergraph_25intersect(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_inp) { + struct __pyx_obj_5_cdec_Lattice *__pyx_v_lat = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("intersect", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":89 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":117 + * """hg.intersect(Lattice/string): Intersect the hypergraph with the provided reference.""" + * cdef Lattice lat + * if isinstance(inp, Lattice): # <<<<<<<<<<<<<< + * lat = <Lattice> inp + * elif isinstance(inp, basestring): + */ + __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Lattice)); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_inp, __pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":118 + * cdef Lattice lat + * if isinstance(inp, Lattice): + * lat = <Lattice> inp # <<<<<<<<<<<<<< + * elif isinstance(inp, basestring): + * lat = Lattice(inp) + */ + __Pyx_INCREF(((PyObject *)((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_inp))); + __pyx_v_lat = ((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_inp); + goto __pyx_L3; + } + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":119 + * if isinstance(inp, Lattice): + * lat = <Lattice> inp + * elif isinstance(inp, basestring): # <<<<<<<<<<<<<< + * lat = Lattice(inp) + * else: + */ + __pyx_t_1 = __pyx_builtin_basestring; + __Pyx_INCREF(__pyx_t_1); + __pyx_t_2 = PyObject_IsInstance(__pyx_v_inp, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":120 + * lat = <Lattice> inp + * elif isinstance(inp, basestring): + * lat = Lattice(inp) # <<<<<<<<<<<<<< + * else: + * raise TypeError('cannot intersect hypergraph with %s' % type(inp)) + */ + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_inp); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_inp); + __Pyx_GIVEREF(__pyx_v_inp); + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Lattice)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_v_lat = ((struct __pyx_obj_5_cdec_Lattice *)__pyx_t_3); + __pyx_t_3 = 0; + goto __pyx_L3; + } + /*else*/ { + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":122 + * lat = Lattice(inp) + * else: + * raise TypeError('cannot intersect hypergraph with %s' % type(inp)) # <<<<<<<<<<<<<< + * return hypergraph.Intersect(lat.lattice[0], self.hg) * - * def intersect(self, Lattice lat): + */ + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), ((PyObject *)Py_TYPE(__pyx_v_inp))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3)); + __Pyx_GIVEREF(((PyObject *)__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[3]; __pyx_lineno = 122; __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_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L3:; + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":123 + * else: + * raise TypeError('cannot intersect hypergraph with %s' % type(inp)) * return hypergraph.Intersect(lat.lattice[0], self.hg) # <<<<<<<<<<<<<< * * def prune(self, beam_alpha=0, density=0, **kwargs): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(HG::Intersect((__pyx_v_lat->lattice[0]), __pyx_v_self->hg)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyBool_FromLong(HG::Intersect((__pyx_v_lat->lattice[0]), __pyx_v_self->hg)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("_cdec.Hypergraph.intersect", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_lat); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_25prune(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_25prune(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5_cdec_10Hypergraph_28prune(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_27prune[] = "hg.prune(beam_alpha=0, density=0): Prune the hypergraph.\n beam_alpha: use beam pruning\n density: use density pruning"; +static PyObject *__pyx_pw_5_cdec_10Hypergraph_28prune(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_beam_alpha = 0; PyObject *__pyx_v_density = 0; PyObject *__pyx_v_kwargs = 0; @@ -10049,7 +10521,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_25prune(PyObject *__pyx_v_self, Py } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "prune") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "prune") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -10064,28 +10536,28 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_25prune(PyObject *__pyx_v_self, Py } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("prune", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("prune", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0; __Pyx_AddTraceback("_cdec.Hypergraph.prune", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_cdec_10Hypergraph_24prune(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), __pyx_v_beam_alpha, __pyx_v_density, __pyx_v_kwargs); + __pyx_r = __pyx_pf_5_cdec_10Hypergraph_27prune(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), __pyx_v_beam_alpha, __pyx_v_density, __pyx_v_kwargs); __Pyx_XDECREF(__pyx_v_kwargs); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":91 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":125 * return hypergraph.Intersect(lat.lattice[0], self.hg) * * def prune(self, beam_alpha=0, density=0, **kwargs): # <<<<<<<<<<<<<< - * cdef hypergraph.EdgeMask* preserve_mask = NULL - * if 'csplit_preserve_full_word' in kwargs: + * """hg.prune(beam_alpha=0, density=0): Prune the hypergraph. + * beam_alpha: use beam pruning */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_24prune(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_beam_alpha, PyObject *__pyx_v_density, PyObject *__pyx_v_kwargs) { +static PyObject *__pyx_pf_5_cdec_10Hypergraph_27prune(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_beam_alpha, PyObject *__pyx_v_density, PyObject *__pyx_v_kwargs) { std::vector<bool> *__pyx_v_preserve_mask; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -10097,26 +10569,26 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_24prune(struct __pyx_obj_5_cdec_Hy int __pyx_clineno = 0; __Pyx_RefNannySetupContext("prune", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":92 - * - * def prune(self, beam_alpha=0, density=0, **kwargs): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":129 + * beam_alpha: use beam pruning + * density: use density pruning""" * cdef hypergraph.EdgeMask* preserve_mask = NULL # <<<<<<<<<<<<<< * if 'csplit_preserve_full_word' in kwargs: * preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) */ __pyx_v_preserve_mask = NULL; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":93 - * def prune(self, beam_alpha=0, density=0, **kwargs): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":130 + * density: use density pruning""" * cdef hypergraph.EdgeMask* preserve_mask = NULL * if 'csplit_preserve_full_word' in kwargs: # <<<<<<<<<<<<<< * preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) * preserve_mask[0][hypergraph.GetFullWordEdgeIndex(self.hg[0])] = True */ - __pyx_t_1 = ((PyDict_Contains(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s_15)))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s_16), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":94 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":131 * cdef hypergraph.EdgeMask* preserve_mask = NULL * if 'csplit_preserve_full_word' in kwargs: * preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) # <<<<<<<<<<<<<< @@ -10125,7 +10597,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_24prune(struct __pyx_obj_5_cdec_Hy */ __pyx_v_preserve_mask = new std::vector<bool>(__pyx_v_self->hg->edges_.size()); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":95 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":132 * if 'csplit_preserve_full_word' in kwargs: * preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) * preserve_mask[0][hypergraph.GetFullWordEdgeIndex(self.hg[0])] = True # <<<<<<<<<<<<<< @@ -10137,18 +10609,18 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_24prune(struct __pyx_obj_5_cdec_Hy } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":96 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":133 * preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) * preserve_mask[0][hypergraph.GetFullWordEdgeIndex(self.hg[0])] = True * self.hg.PruneInsideOutside(beam_alpha, density, preserve_mask, False, 1, False) # <<<<<<<<<<<<<< * if preserve_mask: * del preserve_mask */ - __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_beam_alpha); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_v_density); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_beam_alpha); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_v_density); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->hg->PruneInsideOutside(__pyx_t_2, __pyx_t_3, __pyx_v_preserve_mask, 0, 1.0, 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":97 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":134 * preserve_mask[0][hypergraph.GetFullWordEdgeIndex(self.hg[0])] = True * self.hg.PruneInsideOutside(beam_alpha, density, preserve_mask, False, 1, False) * if preserve_mask: # <<<<<<<<<<<<<< @@ -10158,7 +10630,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_24prune(struct __pyx_obj_5_cdec_Hy __pyx_t_1 = (__pyx_v_preserve_mask != 0); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":98 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":135 * self.hg.PruneInsideOutside(beam_alpha, density, preserve_mask, False, 1, False) * if preserve_mask: * del preserve_mask # <<<<<<<<<<<<<< @@ -10182,25 +10654,26 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_24prune(struct __pyx_obj_5_cdec_Hy } /* Python wrapper */ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_27lattice(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_27lattice(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_5_cdec_10Hypergraph_30lattice(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_29lattice[] = "hg.lattice() -> Lattice corresponding to the hypergraph."; +static PyObject *__pyx_pw_5_cdec_10Hypergraph_30lattice(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("lattice (wrapper)", 0); - __pyx_r = __pyx_pf_5_cdec_10Hypergraph_26lattice(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self)); + __pyx_r = __pyx_pf_5_cdec_10Hypergraph_29lattice(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":100 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":137 * del preserve_mask * * def lattice(self): # TODO direct hg -> lattice conversion in cdec # <<<<<<<<<<<<<< - * cdef str plf = hypergraph.AsPLF(self.hg[0], True).c_str() - * return Lattice(eval(plf)) + * """hg.lattice() -> Lattice corresponding to the hypergraph.""" + * cdef bytes plf = hypergraph.AsPLF(self.hg[0], True).c_str() */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_26lattice(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { +static PyObject *__pyx_pf_5_cdec_10Hypergraph_29lattice(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { PyObject *__pyx_v_plf = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -10212,38 +10685,37 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_26lattice(struct __pyx_obj_5_cdec_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("lattice", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":101 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":139 * def lattice(self): # TODO direct hg -> lattice conversion in cdec - * cdef str plf = hypergraph.AsPLF(self.hg[0], True).c_str() # <<<<<<<<<<<<<< + * """hg.lattice() -> Lattice corresponding to the hypergraph.""" + * cdef bytes plf = hypergraph.AsPLF(self.hg[0], True).c_str() # <<<<<<<<<<<<<< * return Lattice(eval(plf)) * */ - __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->hg[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->hg[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - if (!(likely(PyString_CheckExact(((PyObject *)__pyx_t_1)))||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(((PyObject *)__pyx_t_1))->tp_name), 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_plf = ((PyObject*)__pyx_t_1); + __pyx_v_plf = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":102 - * def lattice(self): # TODO direct hg -> lattice conversion in cdec - * cdef str plf = hypergraph.AsPLF(self.hg[0], True).c_str() + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":140 + * """hg.lattice() -> Lattice corresponding to the hypergraph.""" + * cdef bytes plf = hypergraph.AsPLF(self.hg[0], True).c_str() * return Lattice(eval(plf)) # <<<<<<<<<<<<<< * - * def reweight(self, weights): + * def plf(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); if (((PyObject *)__pyx_v_plf)) { - if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__plf), ((PyObject *)__pyx_v_plf)) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__plf), ((PyObject *)__pyx_v_plf)) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } if (((PyObject *)__pyx_v_self)) { - if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_plf)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_plf)); @@ -10254,15 +10726,15 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_26lattice(struct __pyx_obj_5_cdec_ __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); __pyx_t_1 = 0; __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_builtin_eval, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_builtin_eval, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __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[3]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __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(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Lattice)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Lattice)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; @@ -10285,25 +10757,91 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_26lattice(struct __pyx_obj_5_cdec_ } /* Python wrapper */ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_29reweight(PyObject *__pyx_v_self, PyObject *__pyx_v_weights); /*proto*/ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_29reweight(PyObject *__pyx_v_self, PyObject *__pyx_v_weights) { +static PyObject *__pyx_pw_5_cdec_10Hypergraph_32plf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_31plf[] = "hg.plf() -> Lattice PLF representation corresponding to the hypergraph."; +static PyObject *__pyx_pw_5_cdec_10Hypergraph_32plf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("reweight (wrapper)", 0); - __pyx_r = __pyx_pf_5_cdec_10Hypergraph_28reweight(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((PyObject *)__pyx_v_weights)); + __Pyx_RefNannySetupContext("plf (wrapper)", 0); + __pyx_r = __pyx_pf_5_cdec_10Hypergraph_31plf(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":104 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":142 * return Lattice(eval(plf)) * + * def plf(self): # <<<<<<<<<<<<<< + * """hg.plf() -> Lattice PLF representation corresponding to the hypergraph.""" + * return bytes(hypergraph.AsPLF(self.hg[0], True).c_str()) + */ + +static PyObject *__pyx_pf_5_cdec_10Hypergraph_31plf(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("plf", 0); + + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":144 + * def plf(self): + * """hg.plf() -> Lattice PLF representation corresponding to the hypergraph.""" + * return bytes(hypergraph.AsPLF(self.hg[0], True).c_str()) # <<<<<<<<<<<<<< + * + * def reweight(self, weights): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->hg[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 144; __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[3]; __pyx_lineno = 144; __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*)(&PyBytes_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 144; __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; + __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_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("_cdec.Hypergraph.plf", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_5_cdec_10Hypergraph_34reweight(PyObject *__pyx_v_self, PyObject *__pyx_v_weights); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_33reweight[] = "hg.reweight(SparseVector/DenseVector): Reweight the hypergraph with a new vector."; +static PyObject *__pyx_pw_5_cdec_10Hypergraph_34reweight(PyObject *__pyx_v_self, PyObject *__pyx_v_weights) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("reweight (wrapper)", 0); + __pyx_r = __pyx_pf_5_cdec_10Hypergraph_33reweight(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((PyObject *)__pyx_v_weights)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":146 + * return bytes(hypergraph.AsPLF(self.hg[0], True).c_str()) + * * def reweight(self, weights): # <<<<<<<<<<<<<< + * """hg.reweight(SparseVector/DenseVector): Reweight the hypergraph with a new vector.""" * if isinstance(weights, SparseVector): - * self.hg.Reweight((<SparseVector> weights).vector[0]) */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_28reweight(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_weights) { +static PyObject *__pyx_pf_5_cdec_10Hypergraph_33reweight(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_weights) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -10314,9 +10852,9 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_28reweight(struct __pyx_obj_5_cdec int __pyx_clineno = 0; __Pyx_RefNannySetupContext("reweight", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":105 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":148 * def reweight(self, weights): + * """hg.reweight(SparseVector/DenseVector): Reweight the hypergraph with a new vector.""" * if isinstance(weights, SparseVector): # <<<<<<<<<<<<<< * self.hg.Reweight((<SparseVector> weights).vector[0]) * elif isinstance(weights, DenseVector): @@ -10327,8 +10865,8 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_28reweight(struct __pyx_obj_5_cdec __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":106 - * def reweight(self, weights): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":149 + * """hg.reweight(SparseVector/DenseVector): Reweight the hypergraph with a new vector.""" * if isinstance(weights, SparseVector): * self.hg.Reweight((<SparseVector> weights).vector[0]) # <<<<<<<<<<<<<< * elif isinstance(weights, DenseVector): @@ -10338,7 +10876,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_28reweight(struct __pyx_obj_5_cdec goto __pyx_L3; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":107 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":150 * if isinstance(weights, SparseVector): * self.hg.Reweight((<SparseVector> weights).vector[0]) * elif isinstance(weights, DenseVector): # <<<<<<<<<<<<<< @@ -10351,7 +10889,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_28reweight(struct __pyx_obj_5_cdec __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":108 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":151 * self.hg.Reweight((<SparseVector> weights).vector[0]) * elif isinstance(weights, DenseVector): * self.hg.Reweight((<DenseVector> weights).vector[0]) # <<<<<<<<<<<<<< @@ -10363,26 +10901,26 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_28reweight(struct __pyx_obj_5_cdec } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":110 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":153 * self.hg.Reweight((<DenseVector> weights).vector[0]) * else: * raise TypeError('cannot reweight hypergraph with %s' % type(weights)) # <<<<<<<<<<<<<< * * property edges: */ - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_16), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 153; __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[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 153; __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[3]; __pyx_lineno = 110; __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[3]; __pyx_lineno = 153; __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[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; @@ -10398,7 +10936,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_28reweight(struct __pyx_obj_5_cdec __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator8(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator9(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_5edges_1__get__(PyObject *__pyx_v_self); /*proto*/ @@ -10411,7 +10949,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_5edges_1__get__(PyObject *__pyx_v_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":113 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":156 * * property edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -10420,14 +10958,14 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_5edges_1__get__(PyObject *__pyx_v_ */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_5edges___get__(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { - struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *__pyx_cur_scope; + struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *)__pyx_ptype_5_cdec___pyx_scope_struct_12___get__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_12___get__, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *)__pyx_ptype_5_cdec___pyx_scope_struct_13___get__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_13___get__, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; @@ -10437,7 +10975,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_5edges___get__(struct __pyx_obj_5_ __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_10Hypergraph_5edges_2generator8, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_5edges_2generator9, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -10455,9 +10993,9 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_5edges___get__(struct __pyx_obj_5_ return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator8(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator9(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { - struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *)__pyx_generator->closure); + struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *)__pyx_generator->closure); PyObject *__pyx_r = NULL; size_t __pyx_t_1; unsigned int __pyx_t_2; @@ -10473,9 +11011,9 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator8(__pyx_Generator return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":115 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":158 * def __get__(self): * cdef unsigned i * for i in range(self.hg.edges_.size()): # <<<<<<<<<<<<<< @@ -10486,16 +11024,16 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator8(__pyx_Generator 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/hypergraph.pxi":116 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":159 * cdef unsigned i * for i in range(self.hg.edges_.size()): * yield HypergraphEdge().init(self.hg, i) # <<<<<<<<<<<<<< * * property nodes: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -10510,7 +11048,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator8(__pyx_Generator __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[3]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -10525,7 +11063,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator8(__pyx_Generator __Pyx_RefNannyFinishContext(); return NULL; } -static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator9(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator10(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_5nodes_1__get__(PyObject *__pyx_v_self); /*proto*/ @@ -10538,7 +11076,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_5nodes_1__get__(PyObject *__pyx_v_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":119 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":162 * * property nodes: * def __get__(self): # <<<<<<<<<<<<<< @@ -10547,14 +11085,14 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_5nodes_1__get__(PyObject *__pyx_v_ */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_5nodes___get__(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { - struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *__pyx_cur_scope; + struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *)__pyx_ptype_5_cdec___pyx_scope_struct_13___get__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_13___get__, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *)__pyx_ptype_5_cdec___pyx_scope_struct_14___get__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_14___get__, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; @@ -10564,7 +11102,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_5nodes___get__(struct __pyx_obj_5_ __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_10Hypergraph_5nodes_2generator9, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_5nodes_2generator10, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -10582,9 +11120,9 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_5nodes___get__(struct __pyx_obj_5_ return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator9(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator10(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { - struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *)__pyx_generator->closure); + struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *)__pyx_generator->closure); PyObject *__pyx_r = NULL; size_t __pyx_t_1; unsigned int __pyx_t_2; @@ -10600,9 +11138,9 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator9(__pyx_Generator return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":121 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":164 * def __get__(self): * cdef unsigned i * for i in range(self.hg.nodes_.size()): # <<<<<<<<<<<<<< @@ -10613,16 +11151,16 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator9(__pyx_Generator 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/hypergraph.pxi":122 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":165 * cdef unsigned i * for i in range(self.hg.nodes_.size()): * yield HypergraphNode().init(self.hg, i) # <<<<<<<<<<<<<< * * property goal: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -10637,7 +11175,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator9(__pyx_Generator __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[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -10664,7 +11202,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_4goal_1__get__(PyObject *__pyx_v_s return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":125 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":168 * * property goal: * def __get__(self): # <<<<<<<<<<<<<< @@ -10682,7 +11220,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4goal___get__(struct __pyx_obj_5_c int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":126 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":169 * property goal: * def __get__(self): * return HypergraphNode().init(self.hg, self.hg.GoalNode()) # <<<<<<<<<<<<<< @@ -10690,9 +11228,9 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4goal___get__(struct __pyx_obj_5_c * property npaths: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1), __pyx_v_self->hg, __pyx_v_self->hg->GoalNode()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1), __pyx_v_self->hg, __pyx_v_self->hg->GoalNode()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; @@ -10723,7 +11261,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_6npaths_1__get__(PyObject *__pyx_v return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":129 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":172 * * property npaths: * def __get__(self): # <<<<<<<<<<<<<< @@ -10740,7 +11278,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6npaths___get__(struct __pyx_obj_5 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":130 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":173 * property npaths: * def __get__(self): * return self.hg.NumberOfPaths() # <<<<<<<<<<<<<< @@ -10748,7 +11286,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6npaths___get__(struct __pyx_obj_5 * def inside_outside(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->hg->NumberOfPaths()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->hg->NumberOfPaths()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -10767,25 +11305,26 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6npaths___get__(struct __pyx_obj_5 } /* Python wrapper */ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_31inside_outside(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_31inside_outside(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_5_cdec_10Hypergraph_36inside_outside(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_35inside_outside[] = "hg.inside_outside() -> SparseVector with inside-outside scores for each feature."; +static PyObject *__pyx_pw_5_cdec_10Hypergraph_36inside_outside(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("inside_outside (wrapper)", 0); - __pyx_r = __pyx_pf_5_cdec_10Hypergraph_30inside_outside(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self)); + __pyx_r = __pyx_pf_5_cdec_10Hypergraph_35inside_outside(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":132 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":175 * return self.hg.NumberOfPaths() * * def inside_outside(self): # <<<<<<<<<<<<<< + * """hg.inside_outside() -> SparseVector with inside-outside scores for each feature.""" * 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) { +static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { FastSparseVector<prob_t> *__pyx_v_result; prob_t __pyx_v_z; struct __pyx_obj_5_cdec_SparseVector *__pyx_v_vector = 0; @@ -10801,17 +11340,17 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("inside_outside", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":133 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":177 * def inside_outside(self): + * """hg.inside_outside() -> SparseVector with inside-outside scores for each feature.""" * 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<prob_t>(); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":134 - * def inside_outside(self): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":178 + * """hg.inside_outside() -> SparseVector with inside-outside scores for each feature.""" * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]() * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) # <<<<<<<<<<<<<< * result[0] /= z @@ -10819,7 +11358,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_ */ __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 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":179 * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]() * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) * result[0] /= z # <<<<<<<<<<<<<< @@ -10828,20 +11367,20 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_ */ (__pyx_v_result[0]) /= __pyx_v_z; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":136 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":180 * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) * result[0] /= z * cdef SparseVector vector = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * vector.vector = new FastSparseVector[double]() * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False) */ - __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_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 180; __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;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 180; __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 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":181 * result[0] /= z * cdef SparseVector vector = SparseVector.__new__(SparseVector) * vector.vector = new FastSparseVector[double]() # <<<<<<<<<<<<<< @@ -10850,7 +11389,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_ */ __pyx_v_vector->vector = new FastSparseVector<double>(); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":138 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":182 * cdef SparseVector vector = SparseVector.__new__(SparseVector) * vector.vector = new FastSparseVector[double]() * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False) # <<<<<<<<<<<<<< @@ -10859,7 +11398,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_ */ __pyx_v_it = new FastSparseVector<prob_t>::const_iterator((__pyx_v_result[0]), 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":140 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":184 * 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()): # <<<<<<<<<<<<<< @@ -10870,7 +11409,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_ 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/hypergraph.pxi":141 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":185 * cdef unsigned i * for i in range(result.size()): * vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second)) # <<<<<<<<<<<<<< @@ -10879,7 +11418,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_ */ __pyx_v_vector->vector->set_value((__pyx_v_it[0]).operator->()->first, log((__pyx_v_it[0]).operator->()->second)); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":142 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":186 * for i in range(result.size()): * vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second)) * pinc(it[0]) # ++it # <<<<<<<<<<<<<< @@ -10889,7 +11428,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_ (++(__pyx_v_it[0])); } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":143 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":187 * vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second)) * pinc(it[0]) # ++it * del it # <<<<<<<<<<<<<< @@ -10898,7 +11437,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_ */ delete __pyx_v_it; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":144 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":188 * pinc(it[0]) # ++it * del it * del result # <<<<<<<<<<<<<< @@ -10907,7 +11446,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_ */ delete __pyx_v_result; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":145 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":189 * del it * del result * return vector # <<<<<<<<<<<<<< @@ -10932,7 +11471,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":152 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":196 * cdef public TRule trule * * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): # <<<<<<<<<<<<<< @@ -10949,7 +11488,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy int __pyx_clineno = 0; __Pyx_RefNannySetupContext("init", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":153 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":197 * * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): * self.hg = hg # <<<<<<<<<<<<<< @@ -10958,7 +11497,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy */ __pyx_v_self->hg = __pyx_v_hg; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":154 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":198 * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): * self.hg = hg * self.edge = &hg.edges_[i] # <<<<<<<<<<<<<< @@ -10967,23 +11506,23 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy */ __pyx_v_self->edge = (&(__pyx_v_hg->edges_[__pyx_v_i])); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":155 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":199 * self.hg = hg * self.edge = &hg.edges_[i] * self.trule = TRule.__new__(TRule) # <<<<<<<<<<<<<< * self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_) * return self */ - __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_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_TRule)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 199; __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;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 199; __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_TRule *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":156 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":200 * self.edge = &hg.edges_[i] * self.trule = TRule.__new__(TRule) * self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_) # <<<<<<<<<<<<<< @@ -10992,7 +11531,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 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":201 * self.trule = TRule.__new__(TRule) * self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_) * return self # <<<<<<<<<<<<<< @@ -11027,7 +11566,7 @@ static Py_ssize_t __pyx_pw_5_cdec_14HypergraphEdge_1__len__(PyObject *__pyx_v_se return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":159 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":203 * return self * * def __len__(self): # <<<<<<<<<<<<<< @@ -11040,7 +11579,7 @@ static Py_ssize_t __pyx_pf_5_cdec_14HypergraphEdge___len__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":160 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":204 * * def __len__(self): * return self.edge.tail_nodes_.size() # <<<<<<<<<<<<<< @@ -11067,7 +11606,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_9head_node_1__get__(PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":163 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":207 * * property head_node: * def __get__(self): # <<<<<<<<<<<<<< @@ -11085,7 +11624,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_9head_node___get__(struct __py int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":164 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":208 * property head_node: * def __get__(self): * return HypergraphNode().init(self.hg, self.edge.head_node_) # <<<<<<<<<<<<<< @@ -11093,9 +11632,9 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_9head_node___get__(struct __py * property tail_nodes: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1), __pyx_v_self->hg, __pyx_v_self->edge->head_node_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1), __pyx_v_self->hg, __pyx_v_self->edge->head_node_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; @@ -11114,7 +11653,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_9head_node___get__(struct __py __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator10(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator11(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_10tail_nodes_1__get__(PyObject *__pyx_v_self); /*proto*/ @@ -11127,7 +11666,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_10tail_nodes_1__get__(PyObject return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":167 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":211 * * property tail_nodes: * def __get__(self): # <<<<<<<<<<<<<< @@ -11136,14 +11675,14 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_10tail_nodes_1__get__(PyObject */ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_10tail_nodes___get__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self) { - struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *__pyx_cur_scope; + struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *)__pyx_ptype_5_cdec___pyx_scope_struct_14___get__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_14___get__, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *)__pyx_ptype_5_cdec___pyx_scope_struct_15___get__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_15___get__, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; @@ -11153,7 +11692,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_10tail_nodes___get__(struct __ __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_14HypergraphEdge_10tail_nodes_2generator10, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator11, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -11171,9 +11710,9 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_10tail_nodes___get__(struct __ return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator10(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator11(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { - struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *)__pyx_generator->closure); + struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *)__pyx_generator->closure); PyObject *__pyx_r = NULL; unsigned int __pyx_t_1; unsigned int __pyx_t_2; @@ -11189,9 +11728,9 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator10(__py return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":169 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":213 * def __get__(self): * cdef unsigned i * for i in range(self.edge.tail_nodes_.size()): # <<<<<<<<<<<<<< @@ -11202,16 +11741,16 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator10(__py 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/hypergraph.pxi":170 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":214 * cdef unsigned i * for i in range(self.edge.tail_nodes_.size()): * yield HypergraphNode().init(self.hg, self.edge.tail_nodes_[i]) # <<<<<<<<<<<<<< * * property span: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->edge->tail_nodes_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->edge->tail_nodes_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -11226,7 +11765,7 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator10(__py __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[3]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -11253,7 +11792,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_4span_1__get__(PyObject *__pyx return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":173 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":217 * * property span: * def __get__(self): # <<<<<<<<<<<<<< @@ -11272,7 +11811,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4span___get__(struct __pyx_obj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":174 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":218 * property span: * def __get__(self): * return (self.edge.i_, self.edge.j_) # <<<<<<<<<<<<<< @@ -11280,11 +11819,11 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4span___get__(struct __pyx_obj * property feature_values: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->edge->i_); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->edge->i_); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromLong(__pyx_v_self->edge->j_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_self->edge->j_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -11321,7 +11860,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_14feature_values_1__get__(PyOb return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":177 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":221 * * property feature_values: * def __get__(self): # <<<<<<<<<<<<<< @@ -11339,20 +11878,20 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_14feature_values___get__(struc int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":178 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":222 * property feature_values: * def __get__(self): * cdef SparseVector vector = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * vector.vector = new FastSparseVector[double](self.edge.feature_values_) * return vector */ - __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_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 222; __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;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 222; __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 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":223 * def __get__(self): * cdef SparseVector vector = SparseVector.__new__(SparseVector) * vector.vector = new FastSparseVector[double](self.edge.feature_values_) # <<<<<<<<<<<<<< @@ -11361,7 +11900,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 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":224 * cdef SparseVector vector = SparseVector.__new__(SparseVector) * vector.vector = new FastSparseVector[double](self.edge.feature_values_) * return vector # <<<<<<<<<<<<<< @@ -11397,7 +11936,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_4prob_1__get__(PyObject *__pyx return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":183 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":227 * * property prob: * def __get__(self): # <<<<<<<<<<<<<< @@ -11414,7 +11953,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4prob___get__(struct __pyx_obj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":184 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":228 * property prob: * def __get__(self): * return self.edge.edge_prob_.as_float() # <<<<<<<<<<<<<< @@ -11422,7 +11961,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4prob___get__(struct __pyx_obj * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->edge->edge_prob_.as_float()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->edge->edge_prob_.as_float()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -11446,8 +11985,8 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_3__richcmp__(PyObject *__pyx_v PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_HypergraphEdge, 1, "x", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_HypergraphEdge, 1, "y", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_HypergraphEdge, 1, "x", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_HypergraphEdge, 1, "y", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_x), ((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_y), ((int)__pyx_v_op)); goto __pyx_L0; __pyx_L1_error:; @@ -11457,7 +11996,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_3__richcmp__(PyObject *__pyx_v return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":186 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":230 * return self.edge.edge_prob_.as_float() * * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op): # <<<<<<<<<<<<<< @@ -11475,7 +12014,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__richcmp__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":189 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":233 * if op == 2: # == * return x.edge == y.edge * elif op == 3: # != # <<<<<<<<<<<<<< @@ -11484,7 +12023,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ */ switch (__pyx_v_op) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":187 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":231 * * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op): * if op == 2: # == # <<<<<<<<<<<<<< @@ -11493,7 +12032,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ */ case 2: - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":188 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":232 * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op): * if op == 2: # == * return x.edge == y.edge # <<<<<<<<<<<<<< @@ -11501,14 +12040,14 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ * return not (x == y) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_x->edge == __pyx_v_y->edge)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_x->edge == __pyx_v_y->edge)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 232; __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/hypergraph.pxi":189 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":233 * if op == 2: # == * return x.edge == y.edge * elif op == 3: # != # <<<<<<<<<<<<<< @@ -11517,7 +12056,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ */ case 3: - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":190 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":234 * return x.edge == y.edge * elif op == 3: # != * return not (x == y) # <<<<<<<<<<<<<< @@ -11525,11 +12064,10 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ * */ __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[3]; __pyx_lineno = 190; __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[3]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 234; __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[3]; __pyx_lineno = 234; __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[3]; __pyx_lineno = 190; __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[3]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -11537,18 +12075,18 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ break; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":191 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":235 * elif op == 3: # != * return not (x == y) * raise NotImplemented('comparison not implemented for HypergraphEdge') # <<<<<<<<<<<<<< * * cdef class HypergraphNode: */ - __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_18), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_19), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; __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[3]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; @@ -11573,7 +12111,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_5trule_1__get__(PyObject *__py return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":150 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":194 * cdef hypergraph.Hypergraph* hg * cdef hypergraph.HypergraphEdge* edge * cdef public TRule trule # <<<<<<<<<<<<<< @@ -11615,7 +12153,7 @@ 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_TRule))))) {__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 = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->trule); @@ -11658,7 +12196,7 @@ static int __pyx_pf_5_cdec_14HypergraphEdge_5trule_4__del__(struct __pyx_obj_5_c return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":197 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":241 * cdef hypergraph.HypergraphNode* node * * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): # <<<<<<<<<<<<<< @@ -11671,7 +12209,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphNode_init(struct __pyx_obj_5_cdec_Hy __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":198 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":242 * * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): * self.hg = hg # <<<<<<<<<<<<<< @@ -11680,7 +12218,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphNode_init(struct __pyx_obj_5_cdec_Hy */ __pyx_v_self->hg = __pyx_v_hg; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":199 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":243 * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): * self.hg = hg * self.node = &hg.nodes_[i] # <<<<<<<<<<<<<< @@ -11689,7 +12227,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphNode_init(struct __pyx_obj_5_cdec_Hy */ __pyx_v_self->node = (&(__pyx_v_hg->nodes_[__pyx_v_i])); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":200 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":244 * self.hg = hg * self.node = &hg.nodes_[i] * return self # <<<<<<<<<<<<<< @@ -11707,7 +12245,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphNode_init(struct __pyx_obj_5_cdec_Hy __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator11(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator12(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_8in_edges_1__get__(PyObject *__pyx_v_self); /*proto*/ @@ -11720,7 +12258,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_8in_edges_1__get__(PyObject *_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":203 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":247 * * property in_edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -11729,14 +12267,14 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_8in_edges_1__get__(PyObject *_ */ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_8in_edges___get__(struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_self) { - struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *__pyx_cur_scope; + struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *)__pyx_ptype_5_cdec___pyx_scope_struct_15___get__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_15___get__, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *)__pyx_ptype_5_cdec___pyx_scope_struct_16___get__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_16___get__, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; @@ -11746,7 +12284,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_8in_edges___get__(struct __pyx __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_14HypergraphNode_8in_edges_2generator11, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator12, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -11764,9 +12302,9 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_8in_edges___get__(struct __pyx return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator11(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator12(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { - struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *)__pyx_generator->closure); + struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *)__pyx_generator->closure); PyObject *__pyx_r = NULL; size_t __pyx_t_1; unsigned int __pyx_t_2; @@ -11782,9 +12320,9 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator11(__pyx_G return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":205 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":249 * def __get__(self): * cdef unsigned i * for i in range(self.node.in_edges_.size()): # <<<<<<<<<<<<<< @@ -11795,16 +12333,16 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator11(__pyx_G 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/hypergraph.pxi":206 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":250 * cdef unsigned i * for i in range(self.node.in_edges_.size()): * yield HypergraphEdge().init(self.hg, self.node.in_edges_[i]) # <<<<<<<<<<<<<< * * property out_edges: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->node->in_edges_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->node->in_edges_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -11819,7 +12357,7 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator11(__pyx_G __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[3]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -11834,7 +12372,7 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator11(__pyx_G __Pyx_RefNannyFinishContext(); return NULL; } -static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator12(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator13(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_9out_edges_1__get__(PyObject *__pyx_v_self); /*proto*/ @@ -11847,7 +12385,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_9out_edges_1__get__(PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":209 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":253 * * property out_edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -11856,14 +12394,14 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_9out_edges_1__get__(PyObject * */ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_9out_edges___get__(struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_self) { - struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *__pyx_cur_scope; + struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *)__pyx_ptype_5_cdec___pyx_scope_struct_16___get__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_16___get__, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ *)__pyx_ptype_5_cdec___pyx_scope_struct_17___get__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_17___get__, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; @@ -11873,7 +12411,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_9out_edges___get__(struct __py __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_14HypergraphNode_9out_edges_2generator12, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator13, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -11891,9 +12429,9 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_9out_edges___get__(struct __py return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator12(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator13(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { - struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *)__pyx_generator->closure); + struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ *)__pyx_generator->closure); PyObject *__pyx_r = NULL; size_t __pyx_t_1; unsigned int __pyx_t_2; @@ -11909,9 +12447,9 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator12(__pyx_ return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":211 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":255 * def __get__(self): * cdef unsigned i * for i in range(self.node.out_edges_.size()): # <<<<<<<<<<<<<< @@ -11922,16 +12460,16 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator12(__pyx_ 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/hypergraph.pxi":212 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":256 * cdef unsigned i * for i in range(self.node.out_edges_.size()): * yield HypergraphEdge().init(self.hg, self.node.out_edges_[i]) # <<<<<<<<<<<<<< * * property span: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->node->out_edges_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->node->out_edges_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -11946,7 +12484,7 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator12(__pyx_ __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[3]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -11973,7 +12511,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_4span_1__get__(PyObject *__pyx return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":215 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":259 * * property span: * def __get__(self): # <<<<<<<<<<<<<< @@ -11991,7 +12529,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_4span___get__(struct __pyx_obj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":216 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":260 * property span: * def __get__(self): * return next(self.in_edges).span # <<<<<<<<<<<<<< @@ -11999,12 +12537,12 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_4span___get__(struct __pyx_obj * property cat: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__in_edges); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__in_edges); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyIter_Next(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyIter_Next(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__span); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__span); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -12035,43 +12573,52 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_3cat_1__get__(PyObject *__pyx_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":219 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":263 * * property cat: * def __get__(self): # <<<<<<<<<<<<<< * if self.node.cat_: - * return TDConvert(-self.node.cat_) + * return str(TDConvert(-self.node.cat_).c_str()) */ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_3cat___get__(struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":220 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":264 * property cat: * def __get__(self): * if self.node.cat_: # <<<<<<<<<<<<<< - * return TDConvert(-self.node.cat_) + * return str(TDConvert(-self.node.cat_).c_str()) * */ if (__pyx_v_self->node->cat_) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":221 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":265 * def __get__(self): * if self.node.cat_: - * return TDConvert(-self.node.cat_) # <<<<<<<<<<<<<< + * return str(TDConvert(-self.node.cat_).c_str()) # <<<<<<<<<<<<<< * * def __richcmp__(HypergraphNode x, HypergraphNode y, int op): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_self->node->cat_))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_self->node->cat_)).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 265; __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*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 265; __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; __pyx_t_1 = 0; goto __pyx_L0; goto __pyx_L3; @@ -12082,6 +12629,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_3cat___get__(struct __pyx_obj_ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("_cdec.HypergraphNode.cat.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -12096,8 +12644,8 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_1__richcmp__(PyObject *__pyx_v PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_HypergraphNode, 1, "x", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_HypergraphNode, 1, "y", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_HypergraphNode, 1, "x", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_HypergraphNode, 1, "y", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __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)); goto __pyx_L0; __pyx_L1_error:; @@ -12107,8 +12655,8 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_1__richcmp__(PyObject *__pyx_v return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":223 - * return TDConvert(-self.node.cat_) +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":267 + * return str(TDConvert(-self.node.cat_).c_str()) * * def __richcmp__(HypergraphNode x, HypergraphNode y, int op): # <<<<<<<<<<<<<< * if op == 2: # == @@ -12125,7 +12673,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__richcmp__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":226 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":270 * if op == 2: # == * return x.node == y.node * elif op == 3: # != # <<<<<<<<<<<<<< @@ -12134,7 +12682,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 */ switch (__pyx_v_op) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":224 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":268 * * def __richcmp__(HypergraphNode x, HypergraphNode y, int op): * if op == 2: # == # <<<<<<<<<<<<<< @@ -12143,7 +12691,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 */ case 2: - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":225 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":269 * def __richcmp__(HypergraphNode x, HypergraphNode y, int op): * if op == 2: # == * return x.node == y.node # <<<<<<<<<<<<<< @@ -12151,14 +12699,14 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 * return not (x == y) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_x->node == __pyx_v_y->node)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_x->node == __pyx_v_y->node)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 269; __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/hypergraph.pxi":226 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":270 * if op == 2: # == * return x.node == y.node * elif op == 3: # != # <<<<<<<<<<<<<< @@ -12167,18 +12715,17 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 */ case 3: - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":227 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":271 * return x.node == y.node * elif op == 3: # != * return not (x == y) # <<<<<<<<<<<<<< * raise NotImplemented('comparison not implemented for HypergraphNode') */ __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[3]; __pyx_lineno = 227; __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[3]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 271; __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[3]; __pyx_lineno = 271; __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[3]; __pyx_lineno = 227; __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[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -12186,16 +12733,16 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 break; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":228 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":272 * elif op == 3: # != * return not (x == y) * raise NotImplemented('comparison not implemented for HypergraphNode') # <<<<<<<<<<<<<< */ - __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_20), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_21), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 272; __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[3]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[3]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; @@ -12212,10 +12759,55 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 /* Python wrapper */ 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; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { + __Pyx_RaiseArgtupleInvalid("__cinit__", 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, "__cinit__", 0))) return -1; + __pyx_r = __pyx_pf_5_cdec_7Lattice___cinit__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":6 + * cdef lattice.Lattice* lattice + * + * def __cinit__(self): # <<<<<<<<<<<<<< + * self.lattice = new lattice.Lattice() + * + */ + +static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":7 + * + * def __cinit__(self): + * self.lattice = new lattice.Lattice() # <<<<<<<<<<<<<< + * + * def __init__(self, inp): + */ + __pyx_v_self->lattice = new Lattice(); + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_5_cdec_7Lattice_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_7Lattice_2__init__[] = "Lattice(tuple) -> Lattice from node list.\n Lattice(string) -> Lattice from PLF representation."; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_7Lattice_2__init__; +#endif +static int __pyx_pw_5_cdec_7Lattice_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_inp = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__inp,0}; PyObject* values[1] = {0}; @@ -12234,7 +12826,7 @@ static int __pyx_pw_5_cdec_7Lattice_1__cinit__(PyObject *__pyx_v_self, PyObject 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[4]; __pyx_lineno = 6; __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[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -12245,26 +12837,26 @@ static int __pyx_pw_5_cdec_7Lattice_1__cinit__(PyObject *__pyx_v_self, PyObject } 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[4]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("_cdec.Lattice.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.Lattice.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_cdec_7Lattice___cinit__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), __pyx_v_inp); + __pyx_r = __pyx_pf_5_cdec_7Lattice_2__init__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), __pyx_v_inp); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":6 - * cdef lattice.Lattice* lattice +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":9 + * self.lattice = new lattice.Lattice() * - * def __cinit__(self, inp): # <<<<<<<<<<<<<< - * if isinstance(inp, tuple): - * self.lattice = new lattice.Lattice(len(inp)) + * def __init__(self, inp): # <<<<<<<<<<<<<< + * """Lattice(tuple) -> Lattice from node list. + * Lattice(string) -> Lattice from PLF representation.""" */ -static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, PyObject *__pyx_v_inp) { +static int __pyx_pf_5_cdec_7Lattice_2__init__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, PyObject *__pyx_v_inp) { PyObject *__pyx_v_i = NULL; PyObject *__pyx_v_arcs = NULL; int __pyx_r; @@ -12275,19 +12867,17 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ PyObject *__pyx_t_4 = NULL; PyObject *(*__pyx_t_5)(PyObject *); PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - char *__pyx_t_8; + std::string __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__cinit__", 0); - __Pyx_INCREF(__pyx_v_inp); + __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":7 - * - * def __cinit__(self, inp): + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":12 + * """Lattice(tuple) -> Lattice from node list. + * Lattice(string) -> Lattice from PLF representation.""" * if isinstance(inp, tuple): # <<<<<<<<<<<<<< - * self.lattice = new lattice.Lattice(len(inp)) + * self.lattice.resize(len(inp)) * for i, arcs in enumerate(inp): */ __pyx_t_1 = ((PyObject *)((PyObject*)(&PyTuple_Type))); @@ -12296,22 +12886,22 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":8 - * def __cinit__(self, inp): + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":13 + * Lattice(string) -> Lattice from PLF representation.""" * if isinstance(inp, tuple): - * self.lattice = new lattice.Lattice(len(inp)) # <<<<<<<<<<<<<< + * self.lattice.resize(len(inp)) # <<<<<<<<<<<<<< * for i, arcs in enumerate(inp): * self[i] = arcs */ - __pyx_t_3 = PyObject_Length(__pyx_v_inp); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->lattice = new Lattice(__pyx_t_3); + __pyx_t_3 = PyObject_Length(__pyx_v_inp); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->lattice->resize(__pyx_t_3); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":9 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":14 * if isinstance(inp, tuple): - * self.lattice = new lattice.Lattice(len(inp)) + * self.lattice.resize(len(inp)) * for i, arcs in enumerate(inp): # <<<<<<<<<<<<<< * self[i] = arcs - * else: + * elif isinstance(inp, basestring): */ __Pyx_INCREF(__pyx_int_0); __pyx_t_1 = __pyx_int_0; @@ -12319,7 +12909,7 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ __pyx_t_4 = __pyx_v_inp; __Pyx_INCREF(__pyx_t_4); __pyx_t_3 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_3 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_inp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_inp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; } @@ -12327,23 +12917,23 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ 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++; + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 14; __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++; + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_6 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_6)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -12355,115 +12945,75 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF(__pyx_v_i); __pyx_v_i = __pyx_t_1; - __pyx_t_6 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_6; __pyx_t_6 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":10 - * self.lattice = new lattice.Lattice(len(inp)) + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":15 + * self.lattice.resize(len(inp)) * for i, arcs in enumerate(inp): * self[i] = arcs # <<<<<<<<<<<<<< - * else: - * if isinstance(inp, unicode): + * elif isinstance(inp, basestring): + * lattice.ConvertTextOrPLF(as_str(inp), self.lattice) */ - if (PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_i, __pyx_v_arcs) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_i, __pyx_v_arcs) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L3; } - /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":12 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":16 + * for i, arcs in enumerate(inp): * self[i] = arcs + * elif isinstance(inp, basestring): # <<<<<<<<<<<<<< + * lattice.ConvertTextOrPLF(as_str(inp), self.lattice) * else: - * if isinstance(inp, unicode): # <<<<<<<<<<<<<< - * inp = inp.encode('utf8') - * if not isinstance(inp, str): */ - __pyx_t_1 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_inp, __pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_2) { + __pyx_t_1 = __pyx_builtin_basestring; + __Pyx_INCREF(__pyx_t_1); + __pyx_t_2 = PyObject_IsInstance(__pyx_v_inp, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":13 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":17 + * self[i] = arcs + * elif isinstance(inp, basestring): + * lattice.ConvertTextOrPLF(as_str(inp), self.lattice) # <<<<<<<<<<<<<< * else: - * if isinstance(inp, unicode): - * inp = inp.encode('utf8') # <<<<<<<<<<<<<< - * if not isinstance(inp, str): - * raise TypeError('Cannot create lattice from %s' % type(inp)) - */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_inp, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_21), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __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(__pyx_v_inp); - __pyx_v_inp = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L6; - } - __pyx_L6:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":14 - * if isinstance(inp, unicode): - * inp = inp.encode('utf8') - * if not isinstance(inp, str): # <<<<<<<<<<<<<< - * raise TypeError('Cannot create lattice from %s' % type(inp)) - * self.lattice = new lattice.Lattice() - */ - __pyx_t_4 = ((PyObject *)((PyObject*)(&PyString_Type))); - __Pyx_INCREF(__pyx_t_4); - __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_inp, __pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_7 = (!__pyx_t_2); - if (__pyx_t_7) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":15 - * inp = inp.encode('utf8') - * if not isinstance(inp, str): - * raise TypeError('Cannot create lattice from %s' % type(inp)) # <<<<<<<<<<<<<< - * self.lattice = new lattice.Lattice() - * lattice.ConvertTextToLattice(string(<char *>inp), self.lattice) - */ - __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_22), ((PyObject *)Py_TYPE(__pyx_v_inp))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_4)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); - __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L7; - } - __pyx_L7:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":16 - * if not isinstance(inp, str): - * raise TypeError('Cannot create lattice from %s' % type(inp)) - * self.lattice = new lattice.Lattice() # <<<<<<<<<<<<<< - * lattice.ConvertTextToLattice(string(<char *>inp), self.lattice) - * + * raise TypeError('cannot create lattice from %s' % type(inp)) */ - __pyx_v_self->lattice = new Lattice(); + __pyx_t_1 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_v_inp, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __pyx_convert_string_from_py_(__pyx_t_1); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + LatticeTools::ConvertTextOrPLF(__pyx_t_7, __pyx_v_self->lattice); + goto __pyx_L3; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":17 - * raise TypeError('Cannot create lattice from %s' % type(inp)) - * self.lattice = new lattice.Lattice() - * lattice.ConvertTextToLattice(string(<char *>inp), self.lattice) # <<<<<<<<<<<<<< + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":19 + * lattice.ConvertTextOrPLF(as_str(inp), self.lattice) + * else: + * raise TypeError('cannot create lattice from %s' % type(inp)) # <<<<<<<<<<<<<< * * 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); + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_22), ((PyObject *)Py_TYPE(__pyx_v_inp))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 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_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; @@ -12473,38 +13023,37 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("_cdec.Lattice.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.Lattice.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_arcs); - __Pyx_XDECREF(__pyx_v_inp); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ -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) { +static void __pyx_pw_5_cdec_7Lattice_5__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_5_cdec_7Lattice_5__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_pf_5_cdec_7Lattice_4__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) +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":21 + * raise TypeError('cannot create lattice from %s' % type(inp)) * * 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) { +static void __pyx_pf_5_cdec_7Lattice_4__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 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":22 * * def __dealloc__(self): * del self.lattice # <<<<<<<<<<<<<< @@ -12517,14 +13066,14 @@ static void __pyx_pf_5_cdec_7Lattice_2__dealloc__(CYTHON_UNUSED struct __pyx_obj } /* 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) { +static PyObject *__pyx_pw_5_cdec_7Lattice_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index); /*proto*/ +static PyObject *__pyx_pw_5_cdec_7Lattice_7__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 = 22; __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 = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -12532,12 +13081,12 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_5__getitem__(PyObject *__pyx_v_self, P __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_cdec_7Lattice_4__getitem__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), ((int)__pyx_v_index)); + __pyx_r = __pyx_pf_5_cdec_7Lattice_6__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":22 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":24 * del self.lattice * * def __getitem__(self, int index): # <<<<<<<<<<<<<< @@ -12545,7 +13094,7 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_5__getitem__(PyObject *__pyx_v_self, P * raise IndexError('lattice index out of range') */ -static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index) { +static PyObject *__pyx_pf_5_cdec_7Lattice_6__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; @@ -12567,7 +13116,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_L int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":23 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":25 * * def __getitem__(self, int index): * if not 0 <= index < len(self): # <<<<<<<<<<<<<< @@ -12576,41 +13125,41 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__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 = 23; __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 = 25; __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":24 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":26 * 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 = 24; __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 = 26; __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 = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":25 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":27 * 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 = 25; __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 = 27; __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":26 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":28 * raise IndexError('lattice index out of range') * arcs = [] * cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index] # <<<<<<<<<<<<<< @@ -12619,36 +13168,36 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__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":29 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":31 * cdef lattice.LatticeArc* arc * cdef unsigned i * for i in range(arc_vector.size()): # <<<<<<<<<<<<<< * arc = &arc_vector[i] - * label = unicode(TDConvert(arc.label), 'utf8') + * label = unicode(TDConvert(arc.label).c_str(), 'utf8') */ __pyx_t_5 = __pyx_v_arc_vector.size(); 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":30 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":32 * cdef unsigned i * for i in range(arc_vector.size()): * arc = &arc_vector[i] # <<<<<<<<<<<<<< - * label = unicode(TDConvert(arc.label), 'utf8') + * label = unicode(TDConvert(arc.label).c_str(), 'utf8') * arcs.append((label, arc.cost, arc.dist2next)) */ __pyx_v_arc = (&(__pyx_v_arc_vector[__pyx_v_i])); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":31 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":33 * for i in range(arc_vector.size()): * arc = &arc_vector[i] - * label = unicode(TDConvert(arc.label), 'utf8') # <<<<<<<<<<<<<< + * label = unicode(TDConvert(arc.label).c_str(), '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 = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyBytes_FromString(TD::Convert(__pyx_v_arc->label).c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 33; __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 = 31; __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 = 33; __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)); @@ -12656,25 +13205,25 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__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 = 31; __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 = 33; __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":32 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":34 * arc = &arc_vector[i] - * label = unicode(TDConvert(arc.label), 'utf8') + * label = unicode(TDConvert(arc.label).c_str(), '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 = 32; __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 = 34; __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 = 32; __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 = 34; __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 = 32; __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 = 34; __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)); @@ -12685,19 +13234,19 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__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 = 32; __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 = 34; __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":33 - * label = unicode(TDConvert(arc.label), 'utf8') + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":35 + * label = unicode(TDConvert(arc.label).c_str(), 'utf8') * arcs.append((label, arc.cost, arc.dist2next)) * return tuple(arcs) # <<<<<<<<<<<<<< * * 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 = 33; __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 = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_8)); __pyx_r = ((PyObject *)__pyx_t_8); __pyx_t_8 = 0; @@ -12720,14 +13269,14 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_L } /* Python wrapper */ -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) { +static int __pyx_pw_5_cdec_7Lattice_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index, PyObject *__pyx_v_arcs); /*proto*/ +static int __pyx_pw_5_cdec_7Lattice_9__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 = 35; __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 = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -12735,8 +13284,8 @@ static int __pyx_pw_5_cdec_7Lattice_7__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 = 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)); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arcs), (&PyTuple_Type), 1, "arcs", 1))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_5_cdec_7Lattice_8__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; @@ -12745,7 +13294,7 @@ static int __pyx_pw_5_cdec_7Lattice_7__setitem__(PyObject *__pyx_v_self, PyObjec return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":35 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":37 * return tuple(arcs) * * def __setitem__(self, int index, tuple arcs): # <<<<<<<<<<<<<< @@ -12753,11 +13302,12 @@ static int __pyx_pw_5_cdec_7Lattice_7__setitem__(PyObject *__pyx_v_self, PyObjec * raise IndexError('lattice index out of range') */ -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) { +static int __pyx_pf_5_cdec_7Lattice_8__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; PyObject *__pyx_v_dist2next = NULL; + PyObject *__pyx_v_label_str = NULL; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; @@ -12778,7 +13328,7 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":36 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":38 * * def __setitem__(self, int index, tuple arcs): * if not 0 <= index < len(self): # <<<<<<<<<<<<<< @@ -12787,46 +13337,46 @@ static int __pyx_pf_5_cdec_7Lattice_6__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 = 36; __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 = 38; __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":37 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":39 * 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 = 37; __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 = 39; __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 = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":39 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":41 * raise IndexError('lattice index out of range') * cdef lattice.LatticeArc* arc * for (label, cost, dist2next) in arcs: # <<<<<<<<<<<<<< - * if isinstance(label, unicode): - * label = label.encode('utf8') + * label_str = as_str(label) + * arc = new lattice.LatticeArc(TDConvert(label_str), cost, dist2next) */ if (unlikely(((PyObject *)__pyx_v_arcs) == Py_None)) { 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_filename = __pyx_f[4]; __pyx_lineno = 41; __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++; + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 41; __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; @@ -12838,7 +13388,7 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice 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;} + {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -12854,15 +13404,15 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice __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;} + __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __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 = 41; __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 = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } 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 = 39; __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 = 41; __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; @@ -12872,7 +13422,7 @@ static int __pyx_pf_5_cdec_7Lattice_6__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 = 39; __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 = 41; __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; @@ -12880,7 +13430,7 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __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_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L7_unpacking_done:; } __Pyx_XDECREF(__pyx_v_label); @@ -12893,61 +13443,42 @@ static int __pyx_pf_5_cdec_7Lattice_6__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":40 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":42 * cdef lattice.LatticeArc* arc * for (label, cost, dist2next) in arcs: - * if isinstance(label, unicode): # <<<<<<<<<<<<<< - * label = label.encode('utf8') - * arc = new lattice.LatticeArc(TDConvert(<char *>label), cost, dist2next) - */ - __pyx_t_5 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); - __Pyx_INCREF(__pyx_t_5); - __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_label, __pyx_t_5); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_3) { - - /* "/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) + * label_str = as_str(label) # <<<<<<<<<<<<<< + * arc = new lattice.LatticeArc(TDConvert(label_str), 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 = 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 = 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); - __pyx_v_label = __pyx_t_8; - __pyx_t_8 = 0; - goto __pyx_L8; - } - __pyx_L8:; + __pyx_t_5 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_v_label, NULL)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_XDECREF(((PyObject *)__pyx_v_label_str)); + __pyx_v_label_str = ((PyObject*)__pyx_t_5); + __pyx_t_5 = 0; - /* "/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) # <<<<<<<<<<<<<< + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":43 + * for (label, cost, dist2next) in arcs: + * label_str = as_str(label) + * arc = new lattice.LatticeArc(TDConvert(label_str), 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 = 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); + __pyx_t_11 = PyBytes_AsString(((PyObject *)__pyx_v_label_str)); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 43; __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 = 43; __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 = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_arc = new LatticeArc(TD::Convert(__pyx_t_11), __pyx_t_12, __pyx_t_13); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":43 - * label = label.encode('utf8') - * arc = new lattice.LatticeArc(TDConvert(<char *>label), cost, dist2next) + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":44 + * label_str = as_str(label) + * arc = new lattice.LatticeArc(TDConvert(label_str), cost, dist2next) * self.lattice[0][index].push_back(arc[0]) # <<<<<<<<<<<<<< * del arc * */ ((__pyx_v_self->lattice[0])[__pyx_v_index]).push_back((__pyx_v_arc[0])); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":44 - * arc = new lattice.LatticeArc(TDConvert(<char *>label), cost, dist2next) + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":45 + * arc = new lattice.LatticeArc(TDConvert(label_str), cost, dist2next) * self.lattice[0][index].push_back(arc[0]) * del arc # <<<<<<<<<<<<<< * @@ -12972,22 +13503,23 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice __Pyx_XDECREF(__pyx_v_label); __Pyx_XDECREF(__pyx_v_cost); __Pyx_XDECREF(__pyx_v_dist2next); + __Pyx_XDECREF(__pyx_v_label_str); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ -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) { +static Py_ssize_t __pyx_pw_5_cdec_7Lattice_11__len__(PyObject *__pyx_v_self); /*proto*/ +static Py_ssize_t __pyx_pw_5_cdec_7Lattice_11__len__(PyObject *__pyx_v_self) { Py_ssize_t __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); - __pyx_r = __pyx_pf_5_cdec_7Lattice_8__len__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __pyx_r = __pyx_pf_5_cdec_7Lattice_10__len__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":46 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":47 * del arc * * def __len__(self): # <<<<<<<<<<<<<< @@ -12995,12 +13527,12 @@ static Py_ssize_t __pyx_pw_5_cdec_7Lattice_9__len__(PyObject *__pyx_v_self) { * */ -static Py_ssize_t __pyx_pf_5_cdec_7Lattice_8__len__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { +static Py_ssize_t __pyx_pf_5_cdec_7Lattice_10__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":47 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":48 * * def __len__(self): * return self.lattice.size() # <<<<<<<<<<<<<< @@ -13017,44 +13549,53 @@ static Py_ssize_t __pyx_pf_5_cdec_7Lattice_8__len__(struct __pyx_obj_5_cdec_Latt } /* Python wrapper */ -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) { +static PyObject *__pyx_pw_5_cdec_7Lattice_13__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_5_cdec_7Lattice_13__str__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); - __pyx_r = __pyx_pf_5_cdec_7Lattice_10__str__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __pyx_r = __pyx_pf_5_cdec_7Lattice_12__str__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":49 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":50 * return self.lattice.size() * * def __str__(self): # <<<<<<<<<<<<<< - * return hypergraph.AsPLF(self.lattice[0], True).c_str() + * return str(hypergraph.AsPLF(self.lattice[0], True).c_str()) * */ -static PyObject *__pyx_pf_5_cdec_7Lattice_10__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { +static PyObject *__pyx_pf_5_cdec_7Lattice_12__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__str__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":50 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":51 * * def __str__(self): - * return hypergraph.AsPLF(self.lattice[0], True).c_str() # <<<<<<<<<<<<<< + * return str(hypergraph.AsPLF(self.lattice[0], True).c_str()) # <<<<<<<<<<<<<< * - * def __iter__(self): + * def __unicode__(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 = 50; __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 = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 51; __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*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 51; __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; __pyx_t_1 = 0; goto __pyx_L0; @@ -13062,6 +13603,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_10__str__(struct __pyx_obj_5_cdec_Latt goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("_cdec.Lattice.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -13069,36 +13611,109 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_10__str__(struct __pyx_obj_5_cdec_Latt __Pyx_RefNannyFinishContext(); return __pyx_r; } -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_13__iter__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_5_cdec_7Lattice_13__iter__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_5_cdec_7Lattice_15__unicode__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_5_cdec_7Lattice_15__unicode__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__unicode__ (wrapper)", 0); + __pyx_r = __pyx_pf_5_cdec_7Lattice_14__unicode__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":53 + * return str(hypergraph.AsPLF(self.lattice[0], True).c_str()) + * + * def __unicode__(self): # <<<<<<<<<<<<<< + * return unicode(str(self), 'utf8') + * + */ + +static PyObject *__pyx_pf_5_cdec_7Lattice_14__unicode__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__unicode__", 0); + + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":54 + * + * def __unicode__(self): + * return unicode(str(self), 'utf8') # <<<<<<<<<<<<<< + * + * def __iter__(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8)); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__utf8)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("_cdec.Lattice.__unicode__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static PyObject *__pyx_gb_5_cdec_7Lattice_18generator14(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ + +/* Python wrapper */ +static PyObject *__pyx_pw_5_cdec_7Lattice_17__iter__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_5_cdec_7Lattice_17__iter__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0); - __pyx_r = __pyx_pf_5_cdec_7Lattice_12__iter__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __pyx_r = __pyx_pf_5_cdec_7Lattice_16__iter__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":52 - * return hypergraph.AsPLF(self.lattice[0], True).c_str() +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":56 + * return unicode(str(self), 'utf8') * * def __iter__(self): # <<<<<<<<<<<<<< * cdef unsigned i * for i in range(len(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; +static PyObject *__pyx_pf_5_cdec_7Lattice_16__iter__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { + struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__iter__", 0); - __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *)__pyx_ptype_5_cdec___pyx_scope_struct_17___iter__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_17___iter__, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *)__pyx_ptype_5_cdec___pyx_scope_struct_18___iter__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_18___iter__, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; @@ -13108,7 +13723,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_12__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_14generator13, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Lattice_18generator14, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -13126,9 +13741,9 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_12__iter__(struct __pyx_obj_5_cdec_Lat return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_7Lattice_14generator13(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_7Lattice_18generator14(__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); + struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *)__pyx_generator->closure); PyObject *__pyx_r = NULL; Py_ssize_t __pyx_t_1; unsigned int __pyx_t_2; @@ -13143,27 +13758,27 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_14generator13(__pyx_GeneratorObject *_ return NULL; } __pyx_L3_first_run:; - 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 = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":54 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":58 * 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 = 54; __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 = 58; __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":55 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":59 * cdef unsigned i * for i in range(len(self)): * yield self[i] # <<<<<<<<<<<<<< * * 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 = 55; __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 = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; @@ -13177,7 +13792,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_14generator13(__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 = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -13193,16 +13808,17 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_14generator13(__pyx_GeneratorObject *_ } /* 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) { +static PyObject *__pyx_pw_5_cdec_7Lattice_20todot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_7Lattice_19todot[] = "lattice.todot() -> Representation of the lattice in GraphViz dot format."; +static PyObject *__pyx_pw_5_cdec_7Lattice_20todot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("todot (wrapper)", 0); - __pyx_r = __pyx_pf_5_cdec_7Lattice_15todot(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __pyx_r = __pyx_pf_5_cdec_7Lattice_19todot(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_7Lattice_5todot_1lines(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ @@ -13216,33 +13832,33 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_5todot_1lines(PyObject *__pyx_self, CY return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":58 - * +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":63 * def todot(self): + * """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" * def lines(): # <<<<<<<<<<<<<< * yield 'digraph lattice {' * yield 'rankdir = LR;' */ static PyObject *__pyx_pf_5_cdec_7Lattice_5todot_lines(PyObject *__pyx_self) { - struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *__pyx_cur_scope; + struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("lines", 0); - __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *)__pyx_ptype_5_cdec___pyx_scope_struct_19_lines->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_19_lines, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines *)__pyx_ptype_5_cdec___pyx_scope_struct_20_lines->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_20_lines, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_cur_scope); - __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *) __Pyx_CyFunction_GetClosure(__pyx_self); + __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *) __Pyx_CyFunction_GetClosure(__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_7Lattice_5todot_2generator19, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Lattice_5todot_2generator20, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -13260,9 +13876,9 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_5todot_lines(PyObject *__pyx_self) { return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { - struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *)__pyx_generator->closure); + struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines *)__pyx_generator->closure); PyObject *__pyx_r = NULL; PyObject *__pyx_t_1 = NULL; Py_ssize_t __pyx_t_2; @@ -13291,86 +13907,86 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":59 - * def todot(self): + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":64 + * """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" * def lines(): * yield 'digraph lattice {' # <<<<<<<<<<<<<< * yield 'rankdir = LR;' * yield 'node [shape=circle];' */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_27)); - __pyx_r = ((PyObject *)__pyx_kp_s_27); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_26)); + __pyx_r = ((PyObject *)__pyx_kp_s_26); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L4_resume_from_yield:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":60 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":65 * def lines(): * yield 'digraph lattice {' * yield 'rankdir = LR;' # <<<<<<<<<<<<<< * yield 'node [shape=circle];' * for i in range(len(self)): */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_28)); - __pyx_r = ((PyObject *)__pyx_kp_s_28); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_27)); + __pyx_r = ((PyObject *)__pyx_kp_s_27); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); /* return from generator, yielding value */ __pyx_generator->resume_label = 2; return __pyx_r; __pyx_L5_resume_from_yield:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":61 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":66 * yield 'digraph lattice {' * yield 'rankdir = LR;' * yield 'node [shape=circle];' # <<<<<<<<<<<<<< * for i in range(len(self)): * for label, weight, delta in self[i]: */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_29)); - __pyx_r = ((PyObject *)__pyx_kp_s_29); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_28)); + __pyx_r = ((PyObject *)__pyx_kp_s_28); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); /* return from generator, yielding value */ __pyx_generator->resume_label = 3; return __pyx_r; __pyx_L6_resume_from_yield:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":62 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":67 * yield 'rankdir = LR;' * yield 'node [shape=circle];' * for i in range(len(self)): # <<<<<<<<<<<<<< * for label, weight, delta in self[i]: * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) */ - if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __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[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = 0; __pyx_t_4 = NULL; } else { - __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext; } @@ -13379,23 +13995,23 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj 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++; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 67; __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++; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -13407,20 +14023,20 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj __pyx_cur_scope->__pyx_v_i = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":63 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":68 * yield 'node [shape=circle];' * for i in range(len(self)): * for label, weight, delta in self[i]: # <<<<<<<<<<<<<< * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) * yield '%d [shape=doublecircle]' % len(self) */ - __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __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_5 = __pyx_t_1; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { - __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; } @@ -13429,23 +14045,23 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj 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++; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 68; __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++; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_1 = __pyx_t_7(__pyx_t_5); if (unlikely(!__pyx_t_1)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -13461,7 +14077,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj 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;} + {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -13477,15 +14093,15 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj __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;} + __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __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 = 68; __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 = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } 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_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext; @@ -13495,7 +14111,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj __Pyx_GOTREF(__pyx_t_9); 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;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __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; @@ -13503,7 +14119,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __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_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L12_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_label); @@ -13522,21 +14138,21 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj __pyx_cur_scope->__pyx_v_delta = __pyx_t_10; __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":64 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":69 * for i in range(len(self)): * for label, weight, delta in self[i]: * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) # <<<<<<<<<<<<<< * yield '%d [shape=doublecircle]' % len(self) * yield '}' */ - __pyx_t_1 = PyNumber_Add(__pyx_cur_scope->__pyx_v_i, __pyx_cur_scope->__pyx_v_delta); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Add(__pyx_cur_scope->__pyx_v_i, __pyx_cur_scope->__pyx_v_delta); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_label, __pyx_n_s__replace); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_label, __pyx_n_s__replace); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); - __pyx_t_9 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_k_tuple_33), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_k_tuple_32), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_i); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_cur_scope->__pyx_v_i); @@ -13547,7 +14163,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj __Pyx_GIVEREF(__pyx_t_9); __pyx_t_1 = 0; __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_30), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_29), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_9)); __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; __pyx_r = ((PyObject *)__pyx_t_9); @@ -13576,13 +14192,13 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj __Pyx_XGOTREF(__pyx_t_5); __pyx_t_6 = __pyx_cur_scope->__pyx_t_4; __pyx_t_7 = __pyx_cur_scope->__pyx_t_5; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":65 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":70 * for label, weight, delta in self[i]: * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) * yield '%d [shape=doublecircle]' % len(self) # <<<<<<<<<<<<<< @@ -13591,11 +14207,11 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj */ __pyx_t_3 = ((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_3); - __pyx_t_2 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_34), __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_33), __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = ((PyObject *)__pyx_t_5); @@ -13606,23 +14222,24 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj __pyx_generator->resume_label = 5; return __pyx_r; __pyx_L14_resume_from_yield:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":66 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":71 * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) * yield '%d [shape=doublecircle]' % len(self) * yield '}' # <<<<<<<<<<<<<< * return '\n'.join(lines()).encode('utf8') + * */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_35)); - __pyx_r = ((PyObject *)__pyx_kp_s_35); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_34)); + __pyx_r = ((PyObject *)__pyx_kp_s_34); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); /* return from generator, yielding value */ __pyx_generator->resume_label = 6; return __pyx_r; __pyx_L15_resume_from_yield:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; @@ -13642,16 +14259,16 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__pyx_GeneratorObj return NULL; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":57 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":61 * yield self[i] * * def todot(self): # <<<<<<<<<<<<<< + * """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" * def lines(): - * yield 'digraph lattice {' */ -static PyObject *__pyx_pf_5_cdec_7Lattice_15todot(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { - struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *__pyx_cur_scope; +static PyObject *__pyx_pf_5_cdec_7Lattice_19todot(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { + struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *__pyx_cur_scope; PyObject *__pyx_v_lines = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -13662,7 +14279,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_15todot(struct __pyx_obj_5_cdec_Lattic const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("todot", 0); - __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *)__pyx_ptype_5_cdec___pyx_scope_struct_18_todot->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_18_todot, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *)__pyx_ptype_5_cdec___pyx_scope_struct_19_todot->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_19_todot, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; @@ -13672,41 +14289,43 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_15todot(struct __pyx_obj_5_cdec_Lattic __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":58 - * + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":63 * def todot(self): + * """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" * def lines(): # <<<<<<<<<<<<<< * yield 'digraph lattice {' * yield 'rankdir = LR;' */ - __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5_cdec_7Lattice_5todot_1lines, 0, ((PyObject*)__pyx_cur_scope), __pyx_n_s___cdec, ((PyObject *)__pyx_k_codeobj_37)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5_cdec_7Lattice_5todot_1lines, 0, ((PyObject*)__pyx_cur_scope), __pyx_n_s___cdec, ((PyObject *)__pyx_k_codeobj_36)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_lines = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":67 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":72 * yield '%d [shape=doublecircle]' % len(self) * yield '}' * return '\n'.join(lines()).encode('utf8') # <<<<<<<<<<<<<< + * + * def as_hypergraph(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_39), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_38), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_Call(__pyx_v_lines, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_v_lines, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __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[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __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[4]; __pyx_lineno = 67; __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[4]; __pyx_lineno = 72; __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_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_40), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_39), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; @@ -13729,7 +14348,115 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_15todot(struct __pyx_obj_5_cdec_Lattic return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":3 +/* Python wrapper */ +static PyObject *__pyx_pw_5_cdec_7Lattice_22as_hypergraph(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_7Lattice_21as_hypergraph[] = "lattice.as_hypergraph() -> Hypergraph representation of the lattice."; +static PyObject *__pyx_pw_5_cdec_7Lattice_22as_hypergraph(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("as_hypergraph (wrapper)", 0); + __pyx_r = __pyx_pf_5_cdec_7Lattice_21as_hypergraph(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":74 + * return '\n'.join(lines()).encode('utf8') + * + * def as_hypergraph(self): # <<<<<<<<<<<<<< + * """lattice.as_hypergraph() -> Hypergraph representation of the lattice.""" + * cdef Hypergraph result = Hypergraph.__new__(Hypergraph) + */ + +static PyObject *__pyx_pf_5_cdec_7Lattice_21as_hypergraph(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { + struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_result = 0; + PyObject *__pyx_v_plf = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + std::string __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("as_hypergraph", 0); + + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":76 + * def as_hypergraph(self): + * """lattice.as_hypergraph() -> Hypergraph representation of the lattice.""" + * cdef Hypergraph result = Hypergraph.__new__(Hypergraph) # <<<<<<<<<<<<<< + * result.hg = new hypergraph.Hypergraph() + * cdef bytes plf = str(self) + */ + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_Hypergraph)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_Hypergraph)))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_result = ((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":77 + * """lattice.as_hypergraph() -> Hypergraph representation of the lattice.""" + * cdef Hypergraph result = Hypergraph.__new__(Hypergraph) + * result.hg = new hypergraph.Hypergraph() # <<<<<<<<<<<<<< + * cdef bytes plf = str(self) + * hypergraph.ReadFromPLF(plf, result.hg) + */ + __pyx_v_result->hg = new Hypergraph(); + + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":78 + * cdef Hypergraph result = Hypergraph.__new__(Hypergraph) + * result.hg = new hypergraph.Hypergraph() + * cdef bytes plf = str(self) # <<<<<<<<<<<<<< + * hypergraph.ReadFromPLF(plf, result.hg) + * return result + */ + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_plf = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; + + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":79 + * result.hg = new hypergraph.Hypergraph() + * cdef bytes plf = str(self) + * hypergraph.ReadFromPLF(plf, result.hg) # <<<<<<<<<<<<<< + * return result + */ + __pyx_t_3 = __pyx_convert_string_from_py_(((PyObject *)__pyx_v_plf)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + HypergraphIO::ReadFromPLF(__pyx_t_3, __pyx_v_result->hg); + + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":80 + * cdef bytes plf = str(self) + * hypergraph.ReadFromPLF(plf, result.hg) + * return result # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyObject *)__pyx_v_result); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("_cdec.Lattice.as_hypergraph", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XDECREF(__pyx_v_plf); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":3 * cimport mteval * * cdef SufficientStats as_stats(x, y): # <<<<<<<<<<<<<< @@ -13750,7 +14477,7 @@ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject int __pyx_clineno = 0; __Pyx_RefNannySetupContext("as_stats", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":4 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":4 * * cdef SufficientStats as_stats(x, y): * if isinstance(x, SufficientStats): # <<<<<<<<<<<<<< @@ -13763,7 +14490,7 @@ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":5 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":5 * cdef SufficientStats as_stats(x, y): * if isinstance(x, SufficientStats): * return x # <<<<<<<<<<<<<< @@ -13778,15 +14505,14 @@ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject goto __pyx_L3; } - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":6 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":6 * if isinstance(x, SufficientStats): * return x * elif x == 0 and isinstance(y, SufficientStats): # <<<<<<<<<<<<<< * stats = SufficientStats() * stats.stats = new mteval.SufficientStats() */ - __pyx_t_1 = PyObject_RichCompare(__pyx_v_x, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_1 = PyObject_RichCompare(__pyx_v_x, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 6; __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[5]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { @@ -13800,7 +14526,7 @@ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject } if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":7 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":7 * return x * elif x == 0 and isinstance(y, SufficientStats): * stats = SufficientStats() # <<<<<<<<<<<<<< @@ -13812,7 +14538,7 @@ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject __pyx_v_stats = ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":8 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":8 * elif x == 0 and isinstance(y, SufficientStats): * stats = SufficientStats() * stats.stats = new mteval.SufficientStats() # <<<<<<<<<<<<<< @@ -13821,7 +14547,7 @@ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject */ __pyx_v_stats->stats = new SufficientStats(); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":9 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":9 * stats = SufficientStats() * stats.stats = new mteval.SufficientStats() * stats.metric = (<SufficientStats> y).metric # <<<<<<<<<<<<<< @@ -13830,7 +14556,7 @@ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject */ __pyx_v_stats->metric = ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_v_y)->metric; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":10 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":10 * stats.stats = new mteval.SufficientStats() * stats.metric = (<SufficientStats> y).metric * return stats # <<<<<<<<<<<<<< @@ -13869,7 +14595,7 @@ static PyObject *__pyx_pw_5_cdec_9Candidate_5words_1__get__(PyObject *__pyx_v_se return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":17 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":17 * * property words: * def __get__(self): # <<<<<<<<<<<<<< @@ -13888,7 +14614,7 @@ static PyObject *__pyx_pf_5_cdec_9Candidate_5words___get__(struct __pyx_obj_5_cd int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":18 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":18 * property words: * def __get__(self): * return unicode(GetString(self.candidate.ewords).c_str(), encoding='utf8') # <<<<<<<<<<<<<< @@ -13939,7 +14665,7 @@ static PyObject *__pyx_pw_5_cdec_9Candidate_4fmap_1__get__(PyObject *__pyx_v_sel return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":21 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":21 * * property fmap: * def __get__(self): # <<<<<<<<<<<<<< @@ -13957,7 +14683,7 @@ static PyObject *__pyx_pf_5_cdec_9Candidate_4fmap___get__(struct __pyx_obj_5_cde int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":22 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":22 * property fmap: * def __get__(self): * cdef SparseVector fmap = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< @@ -13970,7 +14696,7 @@ static PyObject *__pyx_pf_5_cdec_9Candidate_4fmap___get__(struct __pyx_obj_5_cde __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 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":23 * def __get__(self): * cdef SparseVector fmap = SparseVector.__new__(SparseVector) * fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap) # <<<<<<<<<<<<<< @@ -13979,7 +14705,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 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":24 * cdef SparseVector fmap = SparseVector.__new__(SparseVector) * fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap) * return fmap # <<<<<<<<<<<<<< @@ -14015,7 +14741,7 @@ static PyObject *__pyx_pw_5_cdec_9Candidate_5score_1__get__(PyObject *__pyx_v_se return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":14 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":14 * cdef class Candidate: * cdef mteval.const_Candidate* candidate * cdef public float score # <<<<<<<<<<<<<< @@ -14091,7 +14817,7 @@ static void __pyx_pw_5_cdec_15SufficientStats_1__dealloc__(PyObject *__pyx_v_sel __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":30 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":30 * cdef mteval.EvaluationMetric* metric * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -14103,7 +14829,7 @@ static void __pyx_pf_5_cdec_15SufficientStats___dealloc__(CYTHON_UNUSED struct _ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":31 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":31 * * def __dealloc__(self): * del self.stats # <<<<<<<<<<<<<< @@ -14126,7 +14852,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_5score_1__get__(PyObject *__p return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":34 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":34 * * property score: * def __get__(self): # <<<<<<<<<<<<<< @@ -14143,7 +14869,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_5score___get__(struct __pyx_o int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":35 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":35 * property score: * def __get__(self): * return self.metric.ComputeScore(self.stats[0]) # <<<<<<<<<<<<<< @@ -14180,11 +14906,11 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_6detail_1__get__(PyObject *__ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":38 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":38 * * property detail: * def __get__(self): # <<<<<<<<<<<<<< - * return self.metric.DetailedScore(self.stats[0]).c_str() + * return str(self.metric.DetailedScore(self.stats[0]).c_str()) * */ @@ -14192,22 +14918,31 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_6detail___get__(struct __pyx_ PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":39 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":39 * property detail: * def __get__(self): - * return self.metric.DetailedScore(self.stats[0]).c_str() # <<<<<<<<<<<<<< + * return str(self.metric.DetailedScore(self.stats[0]).c_str()) # <<<<<<<<<<<<<< * * def __len__(self): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyBytes_FromString(__pyx_v_self->metric->DetailedScore((__pyx_v_self->stats[0])).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 39; __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*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 39; __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; __pyx_t_1 = 0; goto __pyx_L0; @@ -14215,6 +14950,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_6detail___get__(struct __pyx_ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("_cdec.SufficientStats.detail.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -14234,8 +14970,8 @@ static Py_ssize_t __pyx_pw_5_cdec_15SufficientStats_3__len__(PyObject *__pyx_v_s return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":41 - * return self.metric.DetailedScore(self.stats[0]).c_str() +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":41 + * return str(self.metric.DetailedScore(self.stats[0]).c_str()) * * def __len__(self): # <<<<<<<<<<<<<< * return self.stats.size() @@ -14247,7 +14983,7 @@ static Py_ssize_t __pyx_pf_5_cdec_15SufficientStats_2__len__(struct __pyx_obj_5_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":42 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":42 * * def __len__(self): * return self.stats.size() # <<<<<<<<<<<<<< @@ -14262,7 +14998,7 @@ static Py_ssize_t __pyx_pf_5_cdec_15SufficientStats_2__len__(struct __pyx_obj_5_ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator14(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator15(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_15SufficientStats_5__iter__(PyObject *__pyx_v_self); /*proto*/ @@ -14275,7 +15011,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_5__iter__(PyObject *__pyx_v_s return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":44 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":44 * return self.stats.size() * * def __iter__(self): # <<<<<<<<<<<<<< @@ -14284,14 +15020,14 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_5__iter__(PyObject *__pyx_v_s */ static PyObject *__pyx_pf_5_cdec_15SufficientStats_4__iter__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self) { - struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ *__pyx_cur_scope; + struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__iter__", 0); - __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ *)__pyx_ptype_5_cdec___pyx_scope_struct_20___iter__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_20___iter__, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *)__pyx_ptype_5_cdec___pyx_scope_struct_21___iter__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_21___iter__, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; @@ -14301,7 +15037,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_4__iter__(struct __pyx_obj_5_ __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_15SufficientStats_6generator14, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_15SufficientStats_6generator15, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -14319,9 +15055,9 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_4__iter__(struct __pyx_obj_5_ return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator14(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator15(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { - struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ *)__pyx_generator->closure); + struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *)__pyx_generator->closure); PyObject *__pyx_r = NULL; Py_ssize_t __pyx_t_1; PyObject *__pyx_t_2 = NULL; @@ -14339,7 +15075,7 @@ static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator14(__pyx_GeneratorO __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":45 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":45 * * def __iter__(self): * for i in range(len(self)): # <<<<<<<<<<<<<< @@ -14370,16 +15106,16 @@ static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator14(__pyx_GeneratorO 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++; + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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++; + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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); @@ -14398,7 +15134,7 @@ static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator14(__pyx_GeneratorO __pyx_cur_scope->__pyx_v_i = __pyx_t_2; __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":46 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":46 * def __iter__(self): * for i in range(len(self)): * yield self[i] # <<<<<<<<<<<<<< @@ -14462,7 +15198,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_8__getitem__(PyObject *__pyx_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":48 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":48 * yield self[i] * * def __getitem__(self, int index): # <<<<<<<<<<<<<< @@ -14482,7 +15218,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_7__getitem__(struct __pyx_obj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":49 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":49 * * def __getitem__(self, int index): * if not 0 <= index < len(self): # <<<<<<<<<<<<<< @@ -14497,14 +15233,14 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_7__getitem__(struct __pyx_obj __pyx_t_3 = (!__pyx_t_1); if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":50 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":50 * def __getitem__(self, int index): * if not 0 <= index < len(self): * raise IndexError('sufficient stats vector index out of range') # <<<<<<<<<<<<<< * return self.stats[0][index] * */ - __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_42), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_41), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 50; __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; @@ -14513,7 +15249,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_7__getitem__(struct __pyx_obj } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":51 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":51 * if not 0 <= index < len(self): * raise IndexError('sufficient stats vector index out of range') * return self.stats[0][index] # <<<<<<<<<<<<<< @@ -14555,7 +15291,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_10__iadd__(PyObject *__pyx_v_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":53 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":53 * return self.stats[0][index] * * def __iadd__(SufficientStats self, SufficientStats other): # <<<<<<<<<<<<<< @@ -14568,7 +15304,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_9__iadd__(struct __pyx_obj_5_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__iadd__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":54 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":54 * * def __iadd__(SufficientStats self, SufficientStats other): * self.stats[0] += other.stats[0] # <<<<<<<<<<<<<< @@ -14577,7 +15313,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_9__iadd__(struct __pyx_obj_5_ */ (__pyx_v_self->stats[0]) += (__pyx_v_other->stats[0]); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":55 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":55 * def __iadd__(SufficientStats self, SufficientStats other): * self.stats[0] += other.stats[0] * return self # <<<<<<<<<<<<<< @@ -14607,7 +15343,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_12__add__(PyObject *__pyx_v_x return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":57 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":57 * return self * * def __add__(x, y): # <<<<<<<<<<<<<< @@ -14627,7 +15363,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__add__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":58 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":58 * * def __add__(x, y): * cdef SufficientStats sx = as_stats(x, y) # <<<<<<<<<<<<<< @@ -14639,7 +15375,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x __pyx_v_sx = ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":59 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":59 * def __add__(x, y): * cdef SufficientStats sx = as_stats(x, y) * cdef SufficientStats sy = as_stats(y, x) # <<<<<<<<<<<<<< @@ -14651,7 +15387,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x __pyx_v_sy = ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":60 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":60 * cdef SufficientStats sx = as_stats(x, y) * cdef SufficientStats sy = as_stats(y, x) * cdef SufficientStats result = SufficientStats() # <<<<<<<<<<<<<< @@ -14663,7 +15399,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x __pyx_v_result = ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":61 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":61 * cdef SufficientStats sy = as_stats(y, x) * cdef SufficientStats result = SufficientStats() * result.stats = new mteval.SufficientStats(mteval.add(sx.stats[0], sy.stats[0])) # <<<<<<<<<<<<<< @@ -14672,7 +15408,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x */ __pyx_v_result->stats = new SufficientStats(operator+((__pyx_v_sx->stats[0]), (__pyx_v_sy->stats[0]))); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":62 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":62 * cdef SufficientStats result = SufficientStats() * result.stats = new mteval.SufficientStats(mteval.add(sx.stats[0], sy.stats[0])) * result.metric = sx.metric # <<<<<<<<<<<<<< @@ -14681,7 +15417,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x */ __pyx_v_result->metric = __pyx_v_sx->metric; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":63 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":63 * result.stats = new mteval.SufficientStats(mteval.add(sx.stats[0], sy.stats[0])) * result.metric = sx.metric * return result # <<<<<<<<<<<<<< @@ -14760,7 +15496,7 @@ static int __pyx_pw_5_cdec_12CandidateSet_1__cinit__(PyObject *__pyx_v_self, PyO return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":70 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":70 * cdef mteval.CandidateSet* cs * * def __cinit__(self, SegmentEvaluator evaluator): # <<<<<<<<<<<<<< @@ -14773,7 +15509,7 @@ static int __pyx_pf_5_cdec_12CandidateSet___cinit__(struct __pyx_obj_5_cdec_Cand __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":71 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":71 * * def __cinit__(self, SegmentEvaluator evaluator): * self.scorer = new shared_ptr[mteval.SegmentEvaluator](evaluator.scorer[0]) # <<<<<<<<<<<<<< @@ -14782,7 +15518,7 @@ static int __pyx_pf_5_cdec_12CandidateSet___cinit__(struct __pyx_obj_5_cdec_Cand */ __pyx_v_self->scorer = new boost::shared_ptr<SegmentEvaluator>((__pyx_v_evaluator->scorer[0])); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":72 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":72 * def __cinit__(self, SegmentEvaluator evaluator): * self.scorer = new shared_ptr[mteval.SegmentEvaluator](evaluator.scorer[0]) * self.metric = evaluator.metric # <<<<<<<<<<<<<< @@ -14791,7 +15527,7 @@ static int __pyx_pf_5_cdec_12CandidateSet___cinit__(struct __pyx_obj_5_cdec_Cand */ __pyx_v_self->metric = __pyx_v_evaluator->metric; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":73 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":73 * self.scorer = new shared_ptr[mteval.SegmentEvaluator](evaluator.scorer[0]) * self.metric = evaluator.metric * self.cs = new mteval.CandidateSet() # <<<<<<<<<<<<<< @@ -14814,7 +15550,7 @@ static void __pyx_pw_5_cdec_12CandidateSet_3__dealloc__(PyObject *__pyx_v_self) __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":75 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":75 * self.cs = new mteval.CandidateSet() * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -14826,7 +15562,7 @@ static void __pyx_pf_5_cdec_12CandidateSet_2__dealloc__(CYTHON_UNUSED struct __p __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":76 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":76 * * def __dealloc__(self): * del self.scorer # <<<<<<<<<<<<<< @@ -14835,7 +15571,7 @@ static void __pyx_pf_5_cdec_12CandidateSet_2__dealloc__(CYTHON_UNUSED struct __p */ delete __pyx_v_self->scorer; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":77 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":77 * def __dealloc__(self): * del self.scorer * del self.cs # <<<<<<<<<<<<<< @@ -14858,7 +15594,7 @@ static Py_ssize_t __pyx_pw_5_cdec_12CandidateSet_5__len__(PyObject *__pyx_v_self return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":79 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":79 * del self.cs * * def __len__(self): # <<<<<<<<<<<<<< @@ -14871,7 +15607,7 @@ static Py_ssize_t __pyx_pf_5_cdec_12CandidateSet_4__len__(struct __pyx_obj_5_cde __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":80 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":80 * * def __len__(self): * return self.cs.size() # <<<<<<<<<<<<<< @@ -14908,7 +15644,7 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_7__getitem__(PyObject *__pyx_v_s return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":82 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":82 * return self.cs.size() * * def __getitem__(self,int k): # <<<<<<<<<<<<<< @@ -14928,7 +15664,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":83 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":83 * * def __getitem__(self,int k): * if not 0 <= k < self.cs.size(): # <<<<<<<<<<<<<< @@ -14942,14 +15678,14 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_ __pyx_t_2 = (!__pyx_t_1); if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":84 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":84 * def __getitem__(self,int k): * if not 0 <= k < self.cs.size(): * raise IndexError('candidate set index out of range') # <<<<<<<<<<<<<< * cdef Candidate candidate = Candidate() * candidate.candidate = &self.cs[0][k] */ - __pyx_t_3 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_44), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_43), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -14958,7 +15694,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_ } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":85 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":85 * if not 0 <= k < self.cs.size(): * raise IndexError('candidate set index out of range') * cdef Candidate candidate = Candidate() # <<<<<<<<<<<<<< @@ -14970,7 +15706,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_ __pyx_v_candidate = ((struct __pyx_obj_5_cdec_Candidate *)__pyx_t_3); __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":86 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":86 * raise IndexError('candidate set index out of range') * cdef Candidate candidate = Candidate() * candidate.candidate = &self.cs[0][k] # <<<<<<<<<<<<<< @@ -14979,7 +15715,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_ */ __pyx_v_candidate->candidate = (&((__pyx_v_self->cs[0])[__pyx_v_k])); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":87 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":87 * cdef Candidate candidate = Candidate() * candidate.candidate = &self.cs[0][k] * candidate.score = self.metric.ComputeScore(self.cs[0][k].eval_feats) # <<<<<<<<<<<<<< @@ -14988,7 +15724,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_ */ __pyx_v_candidate->score = __pyx_v_self->metric->ComputeScore(((__pyx_v_self->cs[0])[__pyx_v_k]).eval_feats); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":88 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":88 * candidate.candidate = &self.cs[0][k] * candidate.score = self.metric.ComputeScore(self.cs[0][k].eval_feats) * return candidate # <<<<<<<<<<<<<< @@ -15012,7 +15748,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator15(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator16(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_12CandidateSet_9__iter__(PyObject *__pyx_v_self); /*proto*/ @@ -15025,7 +15761,7 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_9__iter__(PyObject *__pyx_v_self return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":90 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":90 * return candidate * * def __iter__(self): # <<<<<<<<<<<<<< @@ -15034,14 +15770,14 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_9__iter__(PyObject *__pyx_v_self */ static PyObject *__pyx_pf_5_cdec_12CandidateSet_8__iter__(struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self) { - struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *__pyx_cur_scope; + struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__iter__", 0); - __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *)__pyx_ptype_5_cdec___pyx_scope_struct_21___iter__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_21___iter__, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ *)__pyx_ptype_5_cdec___pyx_scope_struct_22___iter__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_22___iter__, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; @@ -15051,7 +15787,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_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_12CandidateSet_10generator15, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_12CandidateSet_10generator16, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -15069,9 +15805,9 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_8__iter__(struct __pyx_obj_5_cde return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator15(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator16(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { - struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *)__pyx_generator->closure); + struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ *)__pyx_generator->closure); PyObject *__pyx_r = NULL; Py_ssize_t __pyx_t_1; unsigned int __pyx_t_2; @@ -15088,7 +15824,7 @@ static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator15(__pyx_GeneratorObj __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":92 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":92 * def __iter__(self): * cdef unsigned i * for i in range(len(self)): # <<<<<<<<<<<<<< @@ -15099,7 +15835,7 @@ static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator15(__pyx_GeneratorObj 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/mteval.pxi":93 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":93 * cdef unsigned i * for i in range(len(self)): * yield self[i] # <<<<<<<<<<<<<< @@ -15137,6 +15873,7 @@ static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator15(__pyx_GeneratorObj /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_12CandidateSet_12add_kbest(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_12CandidateSet_11add_kbest[] = "cs.add_kbest(Hypergraph hypergraph, int k) -> Extract K-best hypotheses \n from the hypergraph and add them to the candidate set."; 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; @@ -15196,12 +15933,12 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_12add_kbest(PyObject *__pyx_v_se return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":95 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":95 * yield self[i] * * def add_kbest(self, Hypergraph hypergraph, unsigned k): # <<<<<<<<<<<<<< - * self.cs.AddKBestCandidates(hypergraph.hg[0], k, self.scorer.get()) - * + * """cs.add_kbest(Hypergraph hypergraph, int k) -> Extract K-best hypotheses + * from the hypergraph and add them to the candidate set.""" */ static PyObject *__pyx_pf_5_cdec_12CandidateSet_11add_kbest(struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self, struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_hypergraph, unsigned int __pyx_v_k) { @@ -15209,9 +15946,9 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_11add_kbest(struct __pyx_obj_5_c __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("add_kbest", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":96 - * - * def add_kbest(self, Hypergraph hypergraph, unsigned k): + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":98 + * """cs.add_kbest(Hypergraph hypergraph, int k) -> Extract K-best hypotheses + * from the hypergraph and add them to the candidate set.""" * self.cs.AddKBestCandidates(hypergraph.hg[0], k, self.scorer.get()) # <<<<<<<<<<<<<< * * cdef class SegmentEvaluator: @@ -15233,7 +15970,7 @@ static void __pyx_pw_5_cdec_16SegmentEvaluator_1__dealloc__(PyObject *__pyx_v_se __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":102 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":104 * cdef mteval.EvaluationMetric* metric * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -15245,7 +15982,7 @@ static void __pyx_pf_5_cdec_16SegmentEvaluator___dealloc__(CYTHON_UNUSED struct __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":103 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":105 * * def __dealloc__(self): * del self.scorer # <<<<<<<<<<<<<< @@ -15259,6 +15996,7 @@ static void __pyx_pf_5_cdec_16SegmentEvaluator___dealloc__(CYTHON_UNUSED struct /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_3evaluate(PyObject *__pyx_v_self, PyObject *__pyx_v_sentence); /*proto*/ +static char __pyx_doc_5_cdec_16SegmentEvaluator_2evaluate[] = "se.evaluate(sentence) -> SufficientStats for the given hypothesis."; static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_3evaluate(PyObject *__pyx_v_self, PyObject *__pyx_v_sentence) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -15268,12 +16006,12 @@ static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_3evaluate(PyObject *__pyx_v_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":105 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":107 * del self.scorer * * def evaluate(self, sentence): # <<<<<<<<<<<<<< + * """se.evaluate(sentence) -> SufficientStats for the given hypothesis.""" * cdef vector[WordID] hyp - * cdef SufficientStats sf = SufficientStats() */ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_2evaluate(struct __pyx_obj_5_cdec_SegmentEvaluator *__pyx_v_self, PyObject *__pyx_v_sentence) { @@ -15283,67 +16021,72 @@ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_2evaluate(struct __pyx_obj_5 __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; + std::string __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("evaluate", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":107 - * def evaluate(self, sentence): + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":110 + * """se.evaluate(sentence) -> SufficientStats for the given hypothesis.""" * cdef vector[WordID] hyp * cdef SufficientStats sf = SufficientStats() # <<<<<<<<<<<<<< * sf.metric = self.metric * sf.stats = new mteval.SufficientStats() */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SufficientStats)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SufficientStats)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_sf = ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":108 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":111 * cdef vector[WordID] hyp * cdef SufficientStats sf = SufficientStats() * sf.metric = self.metric # <<<<<<<<<<<<<< * sf.stats = new mteval.SufficientStats() - * ConvertSentence(string(as_str(sentence.strip())), &hyp) + * ConvertSentence(as_str(sentence.strip()), &hyp) */ __pyx_v_sf->metric = __pyx_v_self->metric; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":109 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":112 * cdef SufficientStats sf = SufficientStats() * sf.metric = self.metric * sf.stats = new mteval.SufficientStats() # <<<<<<<<<<<<<< - * ConvertSentence(string(as_str(sentence.strip())), &hyp) + * ConvertSentence(as_str(sentence.strip()), &hyp) * self.scorer.get().Evaluate(hyp, sf.stats) */ __pyx_v_sf->stats = new SufficientStats(); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":110 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":113 * sf.metric = self.metric * sf.stats = new mteval.SufficientStats() - * ConvertSentence(string(as_str(sentence.strip())), &hyp) # <<<<<<<<<<<<<< + * ConvertSentence(as_str(sentence.strip()), &hyp) # <<<<<<<<<<<<<< * self.scorer.get().Evaluate(hyp, sf.stats) * return sf */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 110; __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[5]; __pyx_lineno = 113; __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[5]; __pyx_lineno = 110; __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[5]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - TD::ConvertSentence(std::string(__pyx_f_5_cdec_as_str(__pyx_t_2, NULL)), (&__pyx_v_hyp)); + __pyx_t_1 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_t_2, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_3 = __pyx_convert_string_from_py_(__pyx_t_1); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + TD::ConvertSentence(__pyx_t_3, (&__pyx_v_hyp)); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":111 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":114 * sf.stats = new mteval.SufficientStats() - * ConvertSentence(string(as_str(sentence.strip())), &hyp) + * ConvertSentence(as_str(sentence.strip()), &hyp) * self.scorer.get().Evaluate(hyp, sf.stats) # <<<<<<<<<<<<<< * return sf * */ __pyx_v_self->scorer->get()->Evaluate(__pyx_v_hyp, __pyx_v_sf->stats); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":112 - * ConvertSentence(string(as_str(sentence.strip())), &hyp) + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":115 + * ConvertSentence(as_str(sentence.strip()), &hyp) * self.scorer.get().Evaluate(hyp, sf.stats) * return sf # <<<<<<<<<<<<<< * @@ -15370,6 +16113,7 @@ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_2evaluate(struct __pyx_obj_5 /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_5candidate_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_16SegmentEvaluator_4candidate_set[] = "se.candidate_set() -> Candidate set using this segment evaluator for scoring."; static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_5candidate_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -15379,12 +16123,12 @@ static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_5candidate_set(PyObject *__p return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":114 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":117 * return sf * * def candidate_set(self): # <<<<<<<<<<<<<< + * """se.candidate_set() -> Candidate set using this segment evaluator for scoring.""" * return CandidateSet(self) - * */ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_4candidate_set(struct __pyx_obj_5_cdec_SegmentEvaluator *__pyx_v_self) { @@ -15397,20 +16141,20 @@ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_4candidate_set(struct __pyx_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("candidate_set", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":115 - * + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":119 * def candidate_set(self): + * """se.candidate_set() -> Candidate set using this segment evaluator for scoring.""" * return CandidateSet(self) # <<<<<<<<<<<<<< * * cdef class Scorer: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_CandidateSet)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_CandidateSet)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; @@ -15441,7 +16185,7 @@ static int __pyx_pw_5_cdec_6Scorer_1__cinit__(PyObject *__pyx_v_self, PyObject * static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__name,0}; PyObject* values[1] = {0}; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":121 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":125 * cdef mteval.EvaluationMetric* metric * * def __cinit__(self, bytes name=None): # <<<<<<<<<<<<<< @@ -15466,7 +16210,7 @@ static int __pyx_pw_5_cdec_6Scorer_1__cinit__(PyObject *__pyx_v_self, PyObject * } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 121; __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[5]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -15479,13 +16223,13 @@ static int __pyx_pw_5_cdec_6Scorer_1__cinit__(PyObject *__pyx_v_self, PyObject * } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.Scorer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name), (&PyBytes_Type), 1, "name", 1))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name), (&PyBytes_Type), 1, "name", 1))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_5_cdec_6Scorer___cinit__(((struct __pyx_obj_5_cdec_Scorer *)__pyx_v_self), __pyx_v_name); goto __pyx_L0; __pyx_L1_error:; @@ -15500,12 +16244,13 @@ static int __pyx_pf_5_cdec_6Scorer___cinit__(struct __pyx_obj_5_cdec_Scorer *__p __Pyx_RefNannyDeclarations int __pyx_t_1; char *__pyx_t_2; + std::string *__pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":122 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":126 * * def __cinit__(self, bytes name=None): * if name: # <<<<<<<<<<<<<< @@ -15515,17 +16260,18 @@ static int __pyx_pf_5_cdec_6Scorer___cinit__(struct __pyx_obj_5_cdec_Scorer *__p __pyx_t_1 = (((PyObject *)__pyx_v_name) != Py_None) && (PyBytes_GET_SIZE(((PyObject *)__pyx_v_name)) != 0); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":123 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":127 * def __cinit__(self, bytes name=None): * if name: * self.name = new string(name) # <<<<<<<<<<<<<< * self.metric = mteval.MetricInstance(self.name[0]) * */ - __pyx_t_2 = PyBytes_AsString(((PyObject *)__pyx_v_name)); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->name = new std::string(__pyx_t_2); + __pyx_t_2 = PyBytes_AsString(((PyObject *)__pyx_v_name)); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + try {__pyx_t_3 = new std::string(__pyx_t_2);} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_v_self->name = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":124 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":128 * if name: * self.name = new string(name) * self.metric = mteval.MetricInstance(self.name[0]) # <<<<<<<<<<<<<< @@ -15556,7 +16302,7 @@ static void __pyx_pw_5_cdec_6Scorer_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":126 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":130 * self.metric = mteval.MetricInstance(self.name[0]) * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -15568,7 +16314,7 @@ static void __pyx_pf_5_cdec_6Scorer_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":127 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":131 * * def __dealloc__(self): * del self.name # <<<<<<<<<<<<<< @@ -15605,7 +16351,7 @@ static PyObject *__pyx_pw_5_cdec_6Scorer_5__call__(PyObject *__pyx_v_self, PyObj else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -15616,7 +16362,7 @@ static PyObject *__pyx_pw_5_cdec_6Scorer_5__call__(PyObject *__pyx_v_self, PyObj } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.Scorer.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -15627,11 +16373,11 @@ static PyObject *__pyx_pw_5_cdec_6Scorer_5__call__(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":129 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":133 * del self.name * * def __call__(self, refs): # <<<<<<<<<<<<<< - * if isinstance(refs, unicode) or isinstance(refs, str): + * if isinstance(refs, basestring): * refs = [refs] */ @@ -15644,48 +16390,40 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - Py_ssize_t __pyx_t_5; - PyObject *(*__pyx_t_6)(PyObject *); - PyObject *__pyx_t_7 = NULL; + std::vector<std::vector<WordID> > *__pyx_t_3; + Py_ssize_t __pyx_t_4; + PyObject *(*__pyx_t_5)(PyObject *); + PyObject *__pyx_t_6 = NULL; + std::vector<WordID> *__pyx_t_7; PyObject *__pyx_t_8 = NULL; + std::string __pyx_t_9; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__call__", 0); __Pyx_INCREF(__pyx_v_refs); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":130 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":134 * * def __call__(self, refs): - * if isinstance(refs, unicode) or isinstance(refs, str): # <<<<<<<<<<<<<< + * if isinstance(refs, basestring): # <<<<<<<<<<<<<< * refs = [refs] * cdef vector[vector[WordID]]* refsv = new vector[vector[WordID]]() */ - __pyx_t_1 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); + __pyx_t_1 = __pyx_builtin_basestring; __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_refs, __pyx_t_1); + __pyx_t_2 = PyObject_IsInstance(__pyx_v_refs, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (!__pyx_t_2) { - __pyx_t_1 = ((PyObject *)((PyObject*)(&PyString_Type))); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_refs, __pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_4 = __pyx_t_3; - } else { - __pyx_t_4 = __pyx_t_2; - } - if (__pyx_t_4) { + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":131 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":135 * def __call__(self, refs): - * if isinstance(refs, unicode) or isinstance(refs, str): + * if isinstance(refs, basestring): * refs = [refs] # <<<<<<<<<<<<<< * cdef vector[vector[WordID]]* refsv = new vector[vector[WordID]]() * cdef vector[WordID]* refv */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_refs); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_refs); @@ -15697,95 +16435,101 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":132 - * if isinstance(refs, unicode) or isinstance(refs, str): + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":136 + * if isinstance(refs, basestring): * refs = [refs] * cdef vector[vector[WordID]]* refsv = new vector[vector[WordID]]() # <<<<<<<<<<<<<< * cdef vector[WordID]* refv - * cdef bytes ref_str + * for ref in refs: */ - __pyx_v_refsv = new std::vector<std::vector<WordID> >(); + try {__pyx_t_3 = new std::vector<std::vector<WordID> >();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_v_refsv = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":135 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":138 + * cdef vector[vector[WordID]]* refsv = new vector[vector[WordID]]() * cdef vector[WordID]* refv - * cdef bytes ref_str * for ref in refs: # <<<<<<<<<<<<<< * refv = new vector[WordID]() - * ConvertSentence(string(as_str(ref.strip())), refv) + * ConvertSentence(as_str(ref.strip()), refv) */ if (PyList_CheckExact(__pyx_v_refs) || PyTuple_CheckExact(__pyx_v_refs)) { - __pyx_t_1 = __pyx_v_refs; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0; - __pyx_t_6 = NULL; + __pyx_t_1 = __pyx_v_refs; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0; + __pyx_t_5 = NULL; } else { - __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_refs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_refs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; + __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; } for (;;) { - if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_1)) { - if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break; + 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_7 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; __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; + } 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_7 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { - __pyx_t_7 = __pyx_t_6(__pyx_t_1); - if (unlikely(!__pyx_t_7)) { + __pyx_t_6 = __pyx_t_5(__pyx_t_1); + if (unlikely(!__pyx_t_6)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[5]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } - __Pyx_GOTREF(__pyx_t_7); + __Pyx_GOTREF(__pyx_t_6); } __Pyx_XDECREF(__pyx_v_ref); - __pyx_v_ref = __pyx_t_7; - __pyx_t_7 = 0; + __pyx_v_ref = __pyx_t_6; + __pyx_t_6 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":136 - * cdef bytes ref_str + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":139 + * cdef vector[WordID]* refv * for ref in refs: * refv = new vector[WordID]() # <<<<<<<<<<<<<< - * ConvertSentence(string(as_str(ref.strip())), refv) + * ConvertSentence(as_str(ref.strip()), refv) * refsv.push_back(refv[0]) */ - __pyx_v_refv = new std::vector<WordID>(); + try {__pyx_t_7 = new std::vector<WordID>();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_v_refv = __pyx_t_7; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":137 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":140 * for ref in refs: * refv = new vector[WordID]() - * ConvertSentence(string(as_str(ref.strip())), refv) # <<<<<<<<<<<<<< + * ConvertSentence(as_str(ref.strip()), refv) # <<<<<<<<<<<<<< * refsv.push_back(refv[0]) * del refv */ - __pyx_t_7 = PyObject_GetAttr(__pyx_v_ref, __pyx_n_s__strip); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_v_ref, __pyx_n_s__strip); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - TD::ConvertSentence(std::string(__pyx_f_5_cdec_as_str(__pyx_t_8, NULL)), __pyx_v_refv); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_t_8, NULL)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_9 = __pyx_convert_string_from_py_(__pyx_t_6); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + TD::ConvertSentence(__pyx_t_9, __pyx_v_refv); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":138 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":141 * refv = new vector[WordID]() - * ConvertSentence(string(as_str(ref.strip())), refv) + * ConvertSentence(as_str(ref.strip()), refv) * refsv.push_back(refv[0]) # <<<<<<<<<<<<<< * del refv * cdef unsigned i */ __pyx_v_refsv->push_back((__pyx_v_refv[0])); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":139 - * ConvertSentence(string(as_str(ref.strip())), refv) + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":142 + * ConvertSentence(as_str(ref.strip()), refv) * refsv.push_back(refv[0]) * del refv # <<<<<<<<<<<<<< * cdef unsigned i @@ -15795,19 +16539,19 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":141 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":144 * del refv * cdef unsigned i * cdef SegmentEvaluator evaluator = SegmentEvaluator() # <<<<<<<<<<<<<< * evaluator.metric = self.metric * evaluator.scorer = new shared_ptr[mteval.SegmentEvaluator]( */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SegmentEvaluator)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SegmentEvaluator)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_evaluator = ((struct __pyx_obj_5_cdec_SegmentEvaluator *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":142 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":145 * cdef unsigned i * cdef SegmentEvaluator evaluator = SegmentEvaluator() * evaluator.metric = self.metric # <<<<<<<<<<<<<< @@ -15816,7 +16560,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score */ __pyx_v_evaluator->metric = __pyx_v_self->metric; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":143 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":146 * cdef SegmentEvaluator evaluator = SegmentEvaluator() * evaluator.metric = self.metric * evaluator.scorer = new shared_ptr[mteval.SegmentEvaluator]( # <<<<<<<<<<<<<< @@ -15825,7 +16569,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score */ __pyx_v_evaluator->scorer = new boost::shared_ptr<SegmentEvaluator>(__pyx_v_self->metric->CreateSegmentEvaluator((__pyx_v_refsv[0]))); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":145 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":148 * evaluator.scorer = new shared_ptr[mteval.SegmentEvaluator]( * self.metric.CreateSegmentEvaluator(refsv[0])) * del refsv # in theory should not delete but store in SegmentEvaluator # <<<<<<<<<<<<<< @@ -15834,7 +16578,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score */ delete __pyx_v_refsv; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":146 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":149 * self.metric.CreateSegmentEvaluator(refsv[0])) * del refsv # in theory should not delete but store in SegmentEvaluator * return evaluator # <<<<<<<<<<<<<< @@ -15850,7 +16594,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("_cdec.Scorer.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; @@ -15874,11 +16618,11 @@ static PyObject *__pyx_pw_5_cdec_6Scorer_7__str__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":148 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":151 * return evaluator * * def __str__(self): # <<<<<<<<<<<<<< - * return self.name.c_str() + * return str(self.name.c_str()) * */ @@ -15886,22 +16630,31 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_6__str__(struct __pyx_obj_5_cdec_Scorer PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__str__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":149 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":152 * * def __str__(self): - * return self.name.c_str() # <<<<<<<<<<<<<< + * return str(self.name.c_str()) # <<<<<<<<<<<<<< * * cdef float _compute_score(void* metric_, mteval.SufficientStats* stats): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(__pyx_v_self->name->c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(__pyx_v_self->name->c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 152; __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*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 152; __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; __pyx_t_1 = 0; goto __pyx_L0; @@ -15909,6 +16662,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_6__str__(struct __pyx_obj_5_cdec_Scorer goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("_cdec.Scorer.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -15917,8 +16671,8 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_6__str__(struct __pyx_obj_5_cdec_Scorer return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":151 - * return self.name.c_str() +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":154 + * return str(self.name.c_str()) * * cdef float _compute_score(void* metric_, mteval.SufficientStats* stats): # <<<<<<<<<<<<<< * cdef Metric metric = <Metric> metric_ @@ -15943,7 +16697,7 @@ static float __pyx_f_5_cdec__compute_score(void *__pyx_v_metric_, SufficientStat int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_compute_score", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":152 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":155 * * cdef float _compute_score(void* metric_, mteval.SufficientStats* stats): * cdef Metric metric = <Metric> metric_ # <<<<<<<<<<<<<< @@ -15953,19 +16707,19 @@ static float __pyx_f_5_cdec__compute_score(void *__pyx_v_metric_, SufficientStat __Pyx_INCREF(((PyObject *)((struct __pyx_obj_5_cdec_Metric *)__pyx_v_metric_))); __pyx_v_metric = ((struct __pyx_obj_5_cdec_Metric *)__pyx_v_metric_); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":153 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":156 * cdef float _compute_score(void* metric_, mteval.SufficientStats* stats): * cdef Metric metric = <Metric> metric_ * cdef list ss = [] # <<<<<<<<<<<<<< * cdef unsigned i * for i in range(stats.size()): */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_ss = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":155 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":158 * cdef list ss = [] * cdef unsigned i * for i in range(stats.size()): # <<<<<<<<<<<<<< @@ -15976,38 +16730,38 @@ static float __pyx_f_5_cdec__compute_score(void *__pyx_v_metric_, SufficientStat 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/mteval.pxi":156 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":159 * cdef unsigned i * for i in range(stats.size()): * ss.append(stats[0][i]) # <<<<<<<<<<<<<< * return metric.score(ss) * */ - __pyx_t_1 = PyFloat_FromDouble(((__pyx_v_stats[0])[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(((__pyx_v_stats[0])[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyList_Append(__pyx_v_ss, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyList_Append(__pyx_v_ss, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":157 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":160 * for i in range(stats.size()): * ss.append(stats[0][i]) * return metric.score(ss) # <<<<<<<<<<<<<< * * cdef void _compute_sufficient_stats(void* metric_, */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_metric), __pyx_n_s__score); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_metric), __pyx_n_s__score); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 160; __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[5]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(((PyObject *)__pyx_v_ss)); PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_ss)); __Pyx_GIVEREF(((PyObject *)__pyx_v_ss)); - __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_7; goto __pyx_L0; @@ -16027,7 +16781,7 @@ static float __pyx_f_5_cdec__compute_score(void *__pyx_v_metric_, SufficientStat return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":159 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":162 * return metric.score(ss) * * cdef void _compute_sufficient_stats(void* metric_, # <<<<<<<<<<<<<< @@ -16044,8 +16798,8 @@ static void __pyx_f_5_cdec__compute_sufficient_stats(void *__pyx_v_metric_, std: PyObject *__pyx_t_1 = NULL; size_t __pyx_t_2; unsigned int __pyx_t_3; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; PyObject *__pyx_t_6 = NULL; Py_ssize_t __pyx_t_7; float __pyx_t_8; @@ -16054,7 +16808,7 @@ static void __pyx_f_5_cdec__compute_sufficient_stats(void *__pyx_v_metric_, std: int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_compute_sufficient_stats", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":163 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":166 * vector[string]* refs, * mteval.SufficientStats* out): * cdef Metric metric = <Metric> metric_ # <<<<<<<<<<<<<< @@ -16064,85 +16818,101 @@ static void __pyx_f_5_cdec__compute_sufficient_stats(void *__pyx_v_metric_, std: __Pyx_INCREF(((PyObject *)((struct __pyx_obj_5_cdec_Metric *)__pyx_v_metric_))); __pyx_v_metric = ((struct __pyx_obj_5_cdec_Metric *)__pyx_v_metric_); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":164 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":167 * mteval.SufficientStats* out): * cdef Metric metric = <Metric> metric_ * cdef list refs_ = [] # <<<<<<<<<<<<<< * cdef unsigned i * for i in range(refs.size()): */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_refs_ = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":166 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":169 * cdef list refs_ = [] * cdef unsigned i * for i in range(refs.size()): # <<<<<<<<<<<<<< - * refs_.append(refs[0][i].c_str()) - * cdef list ss = metric.evaluate(hyp.c_str(), refs_) + * refs_.append(str(refs[0][i].c_str())) + * cdef list ss = metric.evaluate(str(hyp.c_str()), refs_) */ __pyx_t_2 = __pyx_v_refs->size(); 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/mteval.pxi":167 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":170 * cdef unsigned i * for i in range(refs.size()): - * refs_.append(refs[0][i].c_str()) # <<<<<<<<<<<<<< - * cdef list ss = metric.evaluate(hyp.c_str(), refs_) + * refs_.append(str(refs[0][i].c_str())) # <<<<<<<<<<<<<< + * cdef list ss = metric.evaluate(str(hyp.c_str()), refs_) * out.fields.resize(len(ss)) */ - __pyx_t_1 = PyBytes_FromString(((__pyx_v_refs[0])[__pyx_v_i]).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(((__pyx_v_refs[0])[__pyx_v_i]).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_4 = PyList_Append(__pyx_v_refs_, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_5 = PyList_Append(__pyx_v_refs_, __pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":168 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":171 * for i in range(refs.size()): - * refs_.append(refs[0][i].c_str()) - * cdef list ss = metric.evaluate(hyp.c_str(), refs_) # <<<<<<<<<<<<<< + * refs_.append(str(refs[0][i].c_str())) + * cdef list ss = metric.evaluate(str(hyp.c_str()), refs_) # <<<<<<<<<<<<<< * out.fields.resize(len(ss)) * for i in range(len(ss)): */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_metric), __pyx_n_s__evaluate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_metric), __pyx_n_s__evaluate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyBytes_FromString(__pyx_v_hyp->c_str()); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyBytes_FromString(__pyx_v_hyp->c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)__pyx_v_refs_)); PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_refs_)); __Pyx_GIVEREF(((PyObject *)__pyx_v_refs_)); - __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __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_6)); __pyx_t_6 = 0; - if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ss = ((PyObject*)__pyx_t_5); - __pyx_t_5 = 0; + if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_ss = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":169 - * refs_.append(refs[0][i].c_str()) - * cdef list ss = metric.evaluate(hyp.c_str(), refs_) + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":172 + * refs_.append(str(refs[0][i].c_str())) + * cdef list ss = metric.evaluate(str(hyp.c_str()), refs_) * out.fields.resize(len(ss)) # <<<<<<<<<<<<<< * for i in range(len(ss)): * 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;} + {__pyx_filename = __pyx_f[5]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __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_t_7 = PyList_GET_SIZE(((PyObject *)__pyx_v_ss)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_out->fields.resize(__pyx_t_7); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":170 - * cdef list ss = metric.evaluate(hyp.c_str(), refs_) + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":173 + * cdef list ss = metric.evaluate(str(hyp.c_str()), refs_) * out.fields.resize(len(ss)) * for i in range(len(ss)): # <<<<<<<<<<<<<< * out.fields[i] = ss[i] @@ -16150,13 +16920,13 @@ 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;} + {__pyx_filename = __pyx_f[5]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __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;} + __pyx_t_7 = PyList_GET_SIZE(((PyObject *)__pyx_v_ss)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 173; __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; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":171 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":174 * out.fields.resize(len(ss)) * for i in range(len(ss)): * out.fields[i] = ss[i] # <<<<<<<<<<<<<< @@ -16165,19 +16935,19 @@ 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, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[5]; __pyx_lineno = 174; __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;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_4 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_ss), __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_4); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; (__pyx_v_out->fields[__pyx_v_i]) = __pyx_t_8; } goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_WriteUnraisable("_cdec._compute_sufficient_stats", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; @@ -16201,32 +16971,35 @@ static int __pyx_pw_5_cdec_6Metric_1__cinit__(PyObject *__pyx_v_self, PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":175 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":178 * cdef class Metric: * cdef Scorer scorer * def __cinit__(self): # <<<<<<<<<<<<<< * self.scorer = Scorer() - * self.scorer.name = new string(as_str(self.__class__.__name__)) + * cdef bytes class_name = self.__class__.__name__ */ static int __pyx_pf_5_cdec_6Metric___cinit__(struct __pyx_obj_5_cdec_Metric *__pyx_v_self) { + PyObject *__pyx_v_class_name = 0; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; + char *__pyx_t_3; + std::string *__pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":176 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":179 * cdef Scorer scorer * def __cinit__(self): * self.scorer = Scorer() # <<<<<<<<<<<<<< - * self.scorer.name = new string(as_str(self.__class__.__name__)) - * self.scorer.metric = mteval.PyMetricInstance(self.scorer.name[0], + * cdef bytes class_name = self.__class__.__name__ + * self.scorer.name = new string(class_name) */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->scorer); @@ -16234,24 +17007,36 @@ static int __pyx_pf_5_cdec_6Metric___cinit__(struct __pyx_obj_5_cdec_Metric *__p __pyx_v_self->scorer = ((struct __pyx_obj_5_cdec_Scorer *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":177 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":180 * def __cinit__(self): * self.scorer = Scorer() - * self.scorer.name = new string(as_str(self.__class__.__name__)) # <<<<<<<<<<<<<< + * cdef bytes class_name = self.__class__.__name__ # <<<<<<<<<<<<<< + * self.scorer.name = new string(class_name) * self.scorer.metric = mteval.PyMetricInstance(self.scorer.name[0], - * <void*> self, _compute_sufficient_stats, _compute_score) */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____name__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____name__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_self->scorer->name = new std::string(__pyx_f_5_cdec_as_str(__pyx_t_2, NULL)); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_class_name = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":178 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":181 * self.scorer = Scorer() - * self.scorer.name = new string(as_str(self.__class__.__name__)) + * cdef bytes class_name = self.__class__.__name__ + * self.scorer.name = new string(class_name) # <<<<<<<<<<<<<< + * self.scorer.metric = mteval.PyMetricInstance(self.scorer.name[0], + * <void*> self, _compute_sufficient_stats, _compute_score) + */ + __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_class_name)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + try {__pyx_t_4 = new std::string(__pyx_t_3);} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_v_self->scorer->name = __pyx_t_4; + + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":182 + * cdef bytes class_name = self.__class__.__name__ + * self.scorer.name = new string(class_name) * self.scorer.metric = mteval.PyMetricInstance(self.scorer.name[0], # <<<<<<<<<<<<<< * <void*> self, _compute_sufficient_stats, _compute_score) * @@ -16266,6 +17051,7 @@ static int __pyx_pf_5_cdec_6Metric___cinit__(struct __pyx_obj_5_cdec_Metric *__p __Pyx_AddTraceback("_cdec.Metric.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_class_name); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -16295,7 +17081,7 @@ static PyObject *__pyx_pw_5_cdec_6Metric_3__call__(PyObject *__pyx_v_self, PyObj else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -16306,7 +17092,7 @@ static PyObject *__pyx_pw_5_cdec_6Metric_3__call__(PyObject *__pyx_v_self, PyObj } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.Metric.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -16317,7 +17103,7 @@ static PyObject *__pyx_pw_5_cdec_6Metric_3__call__(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":181 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":185 * <void*> self, _compute_sufficient_stats, _compute_score) * * def __call__(self, refs): # <<<<<<<<<<<<<< @@ -16335,7 +17121,7 @@ static PyObject *__pyx_pf_5_cdec_6Metric_2__call__(struct __pyx_obj_5_cdec_Metri int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__call__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":182 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":186 * * def __call__(self, refs): * return self.scorer(refs) # <<<<<<<<<<<<<< @@ -16343,12 +17129,12 @@ static PyObject *__pyx_pf_5_cdec_6Metric_2__call__(struct __pyx_obj_5_cdec_Metri * def score(SufficientStats stats): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_refs); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_refs); __Pyx_GIVEREF(__pyx_v_refs); - __pyx_t_2 = PyObject_Call(((PyObject *)__pyx_v_self->scorer), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)__pyx_v_self->scorer), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; @@ -16379,7 +17165,7 @@ static PyObject *__pyx_pw_5_cdec_6Metric_5score(PyObject *__pyx_v_stats, CYTHON_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":184 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":188 * return self.scorer(refs) * * def score(SufficientStats stats): # <<<<<<<<<<<<<< @@ -16392,7 +17178,7 @@ static PyObject *__pyx_pf_5_cdec_6Metric_4score(CYTHON_UNUSED struct __pyx_obj_5 __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("score", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":185 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":189 * * def score(SufficientStats stats): * return 0 # <<<<<<<<<<<<<< @@ -16439,11 +17225,11 @@ static PyObject *__pyx_pw_5_cdec_6Metric_7evaluate(PyObject *__pyx_v_self, PyObj case 1: 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;} + __Pyx_RaiseArgtupleInvalid("evaluate", 1, 2, 2, 1); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "evaluate") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "evaluate") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -16456,7 +17242,7 @@ static PyObject *__pyx_pw_5_cdec_6Metric_7evaluate(PyObject *__pyx_v_self, PyObj } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("evaluate", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("evaluate", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.Metric.evaluate", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -16467,7 +17253,7 @@ static PyObject *__pyx_pw_5_cdec_6Metric_7evaluate(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":187 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":191 * return 0 * * def evaluate(self, hyp, refs): # <<<<<<<<<<<<<< @@ -16484,7 +17270,7 @@ static PyObject *__pyx_pf_5_cdec_6Metric_6evaluate(CYTHON_UNUSED struct __pyx_ob int __pyx_clineno = 0; __Pyx_RefNannySetupContext("evaluate", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":188 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":192 * * def evaluate(self, hyp, refs): * return [] # <<<<<<<<<<<<<< @@ -16492,7 +17278,7 @@ static PyObject *__pyx_pf_5_cdec_6Metric_6evaluate(CYTHON_UNUSED struct __pyx_ob * BLEU = Scorer('IBM_BLEU') */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); 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); __pyx_r = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; @@ -16509,16 +17295,16 @@ static PyObject *__pyx_pf_5_cdec_6Metric_6evaluate(CYTHON_UNUSED struct __pyx_ob __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ -static PyObject *__pyx_pw_5_cdec_3_make_config(PyObject *__pyx_self, PyObject *__pyx_v_config); /*proto*/ -static PyMethodDef __pyx_mdef_5_cdec_3_make_config = {__Pyx_NAMESTR("_make_config"), (PyCFunction)__pyx_pw_5_cdec_3_make_config, METH_O, __Pyx_DOCSTR(0)}; -static PyObject *__pyx_pw_5_cdec_3_make_config(PyObject *__pyx_self, PyObject *__pyx_v_config) { +static PyObject *__pyx_pw_5_cdec_3set_silent(PyObject *__pyx_self, PyObject *__pyx_v_yn); /*proto*/ +static char __pyx_doc_5_cdec_2set_silent[] = "set_silent(bool): Configure the verbosity of cdec."; +static PyMethodDef __pyx_mdef_5_cdec_3set_silent = {__Pyx_NAMESTR("set_silent"), (PyCFunction)__pyx_pw_5_cdec_3set_silent, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_2set_silent)}; +static PyObject *__pyx_pw_5_cdec_3set_silent(PyObject *__pyx_self, PyObject *__pyx_v_yn) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("_make_config (wrapper)", 0); - __pyx_r = __pyx_pf_5_cdec_2_make_config(__pyx_self, ((PyObject *)__pyx_v_config)); + __Pyx_RefNannySetupContext("set_silent (wrapper)", 0); + __pyx_r = __pyx_pf_5_cdec_2set_silent(__pyx_self, ((PyObject *)__pyx_v_yn)); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -16526,20 +17312,71 @@ static PyObject *__pyx_pw_5_cdec_3_make_config(PyObject *__pyx_self, PyObject *_ /* "_cdec.pyx":28 * class ParseFailed(Exception): pass * + * def set_silent(yn): # <<<<<<<<<<<<<< + * """set_silent(bool): Configure the verbosity of cdec.""" + * SetSilent(yn) + */ + +static PyObject *__pyx_pf_5_cdec_2set_silent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_yn) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set_silent", 0); + + /* "_cdec.pyx":30 + * def set_silent(yn): + * """set_silent(bool): Configure the verbosity of cdec.""" + * SetSilent(yn) # <<<<<<<<<<<<<< + * + * def _make_config(config): + */ + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_yn); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + SetSilent(__pyx_t_1); + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("_cdec.set_silent", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ + +/* Python wrapper */ +static PyObject *__pyx_pw_5_cdec_5_make_config(PyObject *__pyx_self, PyObject *__pyx_v_config); /*proto*/ +static PyMethodDef __pyx_mdef_5_cdec_5_make_config = {__Pyx_NAMESTR("_make_config"), (PyCFunction)__pyx_pw_5_cdec_5_make_config, METH_O, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_5_cdec_5_make_config(PyObject *__pyx_self, PyObject *__pyx_v_config) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_make_config (wrapper)", 0); + __pyx_r = __pyx_pf_5_cdec_4_make_config(__pyx_self, ((PyObject *)__pyx_v_config)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "_cdec.pyx":32 + * SetSilent(yn) + * * def _make_config(config): # <<<<<<<<<<<<<< * for key, value in config.items(): * if isinstance(value, dict): */ -static PyObject *__pyx_pf_5_cdec_2_make_config(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_config) { - struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *__pyx_cur_scope; +static PyObject *__pyx_pf_5_cdec_4_make_config(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_config) { + struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_make_config", 0); - __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *)__pyx_ptype_5_cdec___pyx_scope_struct_22__make_config->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_22__make_config, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config *)__pyx_ptype_5_cdec___pyx_scope_struct_23__make_config->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_23__make_config, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; @@ -16549,7 +17386,7 @@ static PyObject *__pyx_pf_5_cdec_2_make_config(CYTHON_UNUSED PyObject *__pyx_sel __Pyx_INCREF(__pyx_cur_scope->__pyx_v_config); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_config); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_4generator16, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_6generator17, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -16567,9 +17404,9 @@ static PyObject *__pyx_pf_5_cdec_2_make_config(CYTHON_UNUSED PyObject *__pyx_sel return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { - struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *)__pyx_generator->closure); + struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config *)__pyx_generator->closure); PyObject *__pyx_r = NULL; PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; @@ -16595,25 +17432,25 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "_cdec.pyx":29 + /* "_cdec.pyx":33 * * def _make_config(config): * for key, value in config.items(): # <<<<<<<<<<<<<< * if isinstance(value, dict): * for name, info in value.items(): */ - __pyx_t_1 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_config, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_config, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __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[0]; __pyx_lineno = 29; __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[0]; __pyx_lineno = 33; __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[0]; __pyx_lineno = 29; __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[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; } @@ -16622,23 +17459,23 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener 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++; + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 33; __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++; + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 33; __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[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -16654,7 +17491,7 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener 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;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -16667,14 +17504,14 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __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;} + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __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 = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } 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_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __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; @@ -16682,7 +17519,7 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __Pyx_GOTREF(__pyx_t_5); 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;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __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; @@ -16690,7 +17527,7 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __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_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L7_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key); @@ -16704,7 +17541,7 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __pyx_cur_scope->__pyx_v_value = __pyx_t_6; __pyx_t_6 = 0; - /* "_cdec.pyx":30 + /* "_cdec.pyx":34 * def _make_config(config): * for key, value in config.items(): * if isinstance(value, dict): # <<<<<<<<<<<<<< @@ -16717,23 +17554,23 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_9) { - /* "_cdec.pyx":31 + /* "_cdec.pyx":35 * for key, value in config.items(): * if isinstance(value, dict): * for name, info in value.items(): # <<<<<<<<<<<<<< * yield key, '%s %s' % (name, info) * elif isinstance(value, list): */ - __pyx_t_2 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_value, __pyx_n_s__items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_value, __pyx_n_s__items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) { __pyx_t_2 = __pyx_t_6; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { - __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = Py_TYPE(__pyx_t_2)->tp_iternext; } @@ -16742,23 +17579,23 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener 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++; + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 35; __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++; + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_6 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_6)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -16774,7 +17611,7 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener 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;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -16787,14 +17624,14 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __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;} + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __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 = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } 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_t_12 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_12)->tp_iternext; @@ -16802,7 +17639,7 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __Pyx_GOTREF(__pyx_t_5); 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;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_12), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __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; @@ -16810,7 +17647,7 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __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_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L12_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_name); @@ -16824,14 +17661,14 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __pyx_cur_scope->__pyx_v_info = __pyx_t_7; __pyx_t_7 = 0; - /* "_cdec.pyx":32 + /* "_cdec.pyx":36 * if isinstance(value, dict): * for name, info in value.items(): * yield key, '%s %s' % (name, info) # <<<<<<<<<<<<<< * elif isinstance(value, list): * for name in value: */ - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_cur_scope->__pyx_v_name); @@ -16839,10 +17676,10 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __Pyx_INCREF(__pyx_cur_scope->__pyx_v_info); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_cur_scope->__pyx_v_info); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_info); - __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_45), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_44), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_7)); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_cur_scope->__pyx_v_key); @@ -16876,13 +17713,13 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __pyx_t_4 = __pyx_cur_scope->__pyx_t_3; __pyx_t_10 = __pyx_cur_scope->__pyx_t_4; __pyx_t_11 = __pyx_cur_scope->__pyx_t_5; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L8; } - /* "_cdec.pyx":33 + /* "_cdec.pyx":37 * for name, info in value.items(): * yield key, '%s %s' % (name, info) * elif isinstance(value, list): # <<<<<<<<<<<<<< @@ -16895,7 +17732,7 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_9) { - /* "_cdec.pyx":34 + /* "_cdec.pyx":38 * yield key, '%s %s' % (name, info) * elif isinstance(value, list): * for name in value: # <<<<<<<<<<<<<< @@ -16906,7 +17743,7 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __pyx_t_2 = __pyx_cur_scope->__pyx_v_value; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { - __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = Py_TYPE(__pyx_t_2)->tp_iternext; } @@ -16914,23 +17751,23 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener 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++; + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 38; __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++; + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_6 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_6)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -16942,14 +17779,14 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __pyx_cur_scope->__pyx_v_name = __pyx_t_6; __pyx_t_6 = 0; - /* "_cdec.pyx":35 + /* "_cdec.pyx":39 * elif isinstance(value, list): * for name in value: * yield key, name # <<<<<<<<<<<<<< * else: - * yield key, bytes(value) + * yield key, str(value) */ - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_cur_scope->__pyx_v_key); @@ -16983,29 +17820,29 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __pyx_t_4 = __pyx_cur_scope->__pyx_t_3; __pyx_t_10 = __pyx_cur_scope->__pyx_t_4; __pyx_t_11 = __pyx_cur_scope->__pyx_t_5; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L8; } /*else*/ { - /* "_cdec.pyx":37 + /* "_cdec.pyx":41 * yield key, name * else: - * yield key, bytes(value) # <<<<<<<<<<<<<< + * yield key, str(value) # <<<<<<<<<<<<<< * * cdef class Decoder: */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_value); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_value); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_value); - __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyBytes_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_key); @@ -17030,7 +17867,7 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener __Pyx_XGOTREF(__pyx_t_1); __pyx_t_3 = __pyx_cur_scope->__pyx_t_2; __pyx_t_4 = __pyx_cur_scope->__pyx_t_3; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L8:; } @@ -17054,25 +17891,29 @@ static PyObject *__pyx_gb_5_cdec_4generator16(__pyx_GeneratorObject *__pyx_gener } /* Python wrapper */ -static int __pyx_pw_5_cdec_7Decoder_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_5_cdec_7Decoder_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static int __pyx_pw_5_cdec_7Decoder_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_7Decoder___init__[] = "Decoder('formalism = scfg') -> initialize from configuration string\n Decoder(formalism='scfg') -> initialize from named parameters\n Create a decoder using a given configuration. Formalism is required."; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_7Decoder___init__; +#endif +static int __pyx_pw_5_cdec_7Decoder_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_config_str = 0; PyObject *__pyx_v_config = 0; int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + __Pyx_RefNannySetupContext("__init__ (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 + /* "_cdec.pyx":47 * cdef DenseVector weights * - * def __cinit__(self, config_str=None, **config): # <<<<<<<<<<<<<< - * """ Configuration can be given as a string: - * Decoder('formalism = scfg') + * def __init__(self, config_str=None, **config): # <<<<<<<<<<<<<< + * """Decoder('formalism = scfg') -> initialize from configuration string + * Decoder(formalism='scfg') -> initialize from named parameters */ values[0] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { @@ -17092,7 +17933,7 @@ static int __pyx_pw_5_cdec_7Decoder_1__cinit__(PyObject *__pyx_v_self, PyObject } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_config, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_config, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -17105,21 +17946,21 @@ static int __pyx_pw_5_cdec_7Decoder_1__cinit__(PyObject *__pyx_v_self, PyObject } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_CLEAR(__pyx_v_config); - __Pyx_AddTraceback("_cdec.Decoder.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.Decoder.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_cdec_7Decoder___cinit__(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self), __pyx_v_config_str, __pyx_v_config); + __pyx_r = __pyx_pf_5_cdec_7Decoder___init__(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self), __pyx_v_config_str, __pyx_v_config); __Pyx_XDECREF(__pyx_v_config); __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator20(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_5_cdec_7Decoder_8__init___2generator21(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ -/* "_cdec.pyx":54 +/* "_cdec.pyx":56 * 'csplit', 'tagger', 'lexalign'): * raise InvalidConfig('formalism "%s" unknown' % formalism) * config_str = '\n'.join('%s = %s' % kv for kv in _make_config(config)) # <<<<<<<<<<<<<< @@ -17127,25 +17968,25 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator20(__pyx_Generato * self.dec = new decoder.Decoder(config_stream) */ -static PyObject *__pyx_pf_5_cdec_7Decoder_9__cinit___genexpr(PyObject *__pyx_self) { - struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr *__pyx_cur_scope; +static PyObject *__pyx_pf_5_cdec_7Decoder_8__init___genexpr(PyObject *__pyx_self) { + struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("genexpr", 0); - __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr *)__pyx_ptype_5_cdec___pyx_scope_struct_24_genexpr->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_24_genexpr, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *)__pyx_ptype_5_cdec___pyx_scope_struct_25_genexpr->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_25_genexpr, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_cur_scope); - __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *) __pyx_self; + __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *) __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_7Decoder_9__cinit___2generator20, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Decoder_8__init___2generator21, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -17154,7 +17995,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_9__cinit___genexpr(PyObject *__pyx_sel __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_AddTraceback("_cdec.Decoder.__cinit__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.Decoder.__init__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); @@ -17163,9 +18004,9 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_9__cinit___genexpr(PyObject *__pyx_sel return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator20(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_7Decoder_8__init___2generator21(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { - struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr *)__pyx_generator->closure); + struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *)__pyx_generator->closure); PyObject *__pyx_r = NULL; PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; @@ -17182,16 +18023,16 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator20(__pyx_Generato return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___make_config); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___make_config); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_config)) { __Pyx_RaiseClosureNameError("config"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_config)) { __Pyx_RaiseClosureNameError("config"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_config); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_config); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_config); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __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[0]; __pyx_lineno = 56; __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; @@ -17199,7 +18040,7 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator20(__pyx_Generato __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; } @@ -17208,23 +18049,23 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator20(__pyx_Generato 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++; + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 56; __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++; + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -17235,7 +18076,7 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator20(__pyx_Generato __Pyx_GIVEREF(__pyx_t_3); __pyx_cur_scope->__pyx_v_kv = __pyx_t_3; __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_46), __pyx_cur_scope->__pyx_v_kv); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_45), __pyx_cur_scope->__pyx_v_kv); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); __pyx_r = ((PyObject *)__pyx_t_3); __pyx_t_3 = 0; @@ -17254,7 +18095,7 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator20(__pyx_Generato __Pyx_XGOTREF(__pyx_t_2); __pyx_t_4 = __pyx_cur_scope->__pyx_t_1; __pyx_t_5 = __pyx_cur_scope->__pyx_t_2; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetNone(PyExc_StopIteration); @@ -17272,16 +18113,16 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator20(__pyx_Generato return NULL; } -/* "_cdec.pyx":43 +/* "_cdec.pyx":47 * cdef DenseVector weights * - * def __cinit__(self, config_str=None, **config): # <<<<<<<<<<<<<< - * """ Configuration can be given as a string: - * Decoder('formalism = scfg') + * def __init__(self, config_str=None, **config): # <<<<<<<<<<<<<< + * """Decoder('formalism = scfg') -> initialize from configuration string + * Decoder(formalism='scfg') -> initialize from named parameters */ -static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_config_str, PyObject *__pyx_v_config) { - struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *__pyx_cur_scope; +static int __pyx_pf_5_cdec_7Decoder___init__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_config_str, PyObject *__pyx_v_config) { + struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *__pyx_cur_scope; PyObject *__pyx_v_formalism = NULL; std::istringstream *__pyx_v_config_stream; int __pyx_r; @@ -17296,8 +18137,8 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__cinit__", 0); - __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *)__pyx_ptype_5_cdec___pyx_scope_struct_23___cinit__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_23___cinit__, __pyx_empty_tuple, NULL); + __Pyx_RefNannySetupContext("__init__", 0); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *)__pyx_ptype_5_cdec___pyx_scope_struct_24___init__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_24___init__, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return -1; @@ -17308,9 +18149,9 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_config); __Pyx_INCREF(__pyx_v_config_str); - /* "_cdec.pyx":49 - * Decoder(formalism='scfg') - * """ + /* "_cdec.pyx":51 + * Decoder(formalism='scfg') -> initialize from named parameters + * Create a decoder using a given configuration. Formalism is required.""" * if config_str is None: # <<<<<<<<<<<<<< * formalism = config.get('formalism', None) * if formalism not in ('scfg', 'fst', 'lextrans', 'pb', @@ -17318,22 +18159,22 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ __pyx_t_1 = (__pyx_v_config_str == Py_None); if (__pyx_t_1) { - /* "_cdec.pyx":50 - * """ + /* "_cdec.pyx":52 + * Create a decoder using a given configuration. Formalism is required.""" * if config_str is None: * formalism = config.get('formalism', None) # <<<<<<<<<<<<<< * if formalism not in ('scfg', 'fst', 'lextrans', 'pb', * 'csplit', 'tagger', 'lexalign'): */ - __pyx_t_2 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_config, __pyx_n_s__get); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_config, __pyx_n_s__get); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_47), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_46), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_formalism = __pyx_t_3; __pyx_t_3 = 0; - /* "_cdec.pyx":51 + /* "_cdec.pyx":53 * if config_str is None: * formalism = config.get('formalism', None) * if formalism not in ('scfg', 'fst', 'lextrans', 'pb', # <<<<<<<<<<<<<< @@ -17342,39 +18183,53 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ */ __Pyx_INCREF(__pyx_v_formalism); __pyx_t_3 = __pyx_v_formalism; - __pyx_t_1 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__scfg), Py_NE); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__scfg), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (((int)__pyx_t_1)) { - __pyx_t_4 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__fst), Py_NE); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__fst), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = ((int)__pyx_t_4); } else { __pyx_t_5 = ((int)__pyx_t_1); } if (__pyx_t_5) { - __pyx_t_1 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__lextrans), Py_NE); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__lextrans), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = ((int)__pyx_t_1); } else { __pyx_t_4 = __pyx_t_5; } if (__pyx_t_4) { - __pyx_t_5 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__pb), Py_NE); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__pb), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = ((int)__pyx_t_5); } else { __pyx_t_1 = __pyx_t_4; } if (__pyx_t_1) { - __pyx_t_4 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__csplit), Py_NE); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__csplit), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = ((int)__pyx_t_4); } else { __pyx_t_5 = __pyx_t_1; } if (__pyx_t_5) { - __pyx_t_1 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__tagger), Py_NE); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__tagger), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = ((int)__pyx_t_1); } else { __pyx_t_4 = __pyx_t_5; } if (__pyx_t_4) { - __pyx_t_5 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__lexalign), Py_NE); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__lexalign), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = ((int)__pyx_t_5); } else { __pyx_t_1 = __pyx_t_4; @@ -17383,50 +18238,50 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ __pyx_t_4 = __pyx_t_1; if (__pyx_t_4) { - /* "_cdec.pyx":53 + /* "_cdec.pyx":55 * if formalism not in ('scfg', 'fst', 'lextrans', 'pb', * 'csplit', 'tagger', 'lexalign'): * raise InvalidConfig('formalism "%s" unknown' % formalism) # <<<<<<<<<<<<<< * config_str = '\n'.join('%s = %s' % kv for kv in _make_config(config)) * cdef istringstream* config_stream = new istringstream(config_str) */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__InvalidConfig); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__InvalidConfig); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_48), __pyx_v_formalism); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_47), __pyx_v_formalism); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_2)); __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L4; } __pyx_L4:; - /* "_cdec.pyx":54 + /* "_cdec.pyx":56 * 'csplit', 'tagger', 'lexalign'): * raise InvalidConfig('formalism "%s" unknown' % formalism) * config_str = '\n'.join('%s = %s' % kv for kv in _make_config(config)) # <<<<<<<<<<<<<< * cdef istringstream* config_stream = new istringstream(config_str) * self.dec = new decoder.Decoder(config_stream) */ - __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_39), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_38), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = __pyx_pf_5_cdec_7Decoder_9__cinit___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __pyx_pf_5_cdec_7Decoder_8__init___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __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 = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; @@ -17437,17 +18292,17 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ } __pyx_L3:; - /* "_cdec.pyx":55 + /* "_cdec.pyx":57 * raise InvalidConfig('formalism "%s" unknown' % formalism) * config_str = '\n'.join('%s = %s' % kv for kv in _make_config(config)) * cdef istringstream* config_stream = new istringstream(config_str) # <<<<<<<<<<<<<< * self.dec = new decoder.Decoder(config_stream) * del config_stream */ - __pyx_t_7 = PyBytes_AsString(__pyx_v_config_str); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyBytes_AsString(__pyx_v_config_str); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_config_stream = new std::istringstream(__pyx_t_7); - /* "_cdec.pyx":56 + /* "_cdec.pyx":58 * config_str = '\n'.join('%s = %s' % kv for kv in _make_config(config)) * cdef istringstream* config_stream = new istringstream(config_str) * self.dec = new decoder.Decoder(config_stream) # <<<<<<<<<<<<<< @@ -17456,7 +18311,7 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ */ __pyx_v_self->dec = new Decoder(__pyx_v_config_stream); - /* "_cdec.pyx":57 + /* "_cdec.pyx":59 * cdef istringstream* config_stream = new istringstream(config_str) * self.dec = new decoder.Decoder(config_stream) * del config_stream # <<<<<<<<<<<<<< @@ -17465,23 +18320,23 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ */ delete __pyx_v_config_stream; - /* "_cdec.pyx":58 + /* "_cdec.pyx":60 * self.dec = new decoder.Decoder(config_stream) * del config_stream * self.weights = DenseVector.__new__(DenseVector) # <<<<<<<<<<<<<< * self.weights.vector = &self.dec.CurrentWeightVector() * self.weights.owned = True */ - __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_t_6 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_DenseVector)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __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;} + if (!(likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5_cdec_DenseVector)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __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)); __pyx_v_self->weights = ((struct __pyx_obj_5_cdec_DenseVector *)__pyx_t_6); __pyx_t_6 = 0; - /* "_cdec.pyx":59 + /* "_cdec.pyx":61 * del config_stream * self.weights = DenseVector.__new__(DenseVector) * self.weights.vector = &self.dec.CurrentWeightVector() # <<<<<<<<<<<<<< @@ -17490,7 +18345,7 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ */ __pyx_v_self->weights->vector = (&__pyx_v_self->dec->CurrentWeightVector()); - /* "_cdec.pyx":60 + /* "_cdec.pyx":62 * self.weights = DenseVector.__new__(DenseVector) * self.weights.vector = &self.dec.CurrentWeightVector() * self.weights.owned = True # <<<<<<<<<<<<<< @@ -17505,7 +18360,7 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("_cdec.Decoder.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.Decoder.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_formalism); @@ -17524,7 +18379,7 @@ static void __pyx_pw_5_cdec_7Decoder_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "_cdec.pyx":62 +/* "_cdec.pyx":64 * self.weights.owned = True * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -17536,7 +18391,7 @@ static void __pyx_pf_5_cdec_7Decoder_2__dealloc__(CYTHON_UNUSED struct __pyx_obj __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "_cdec.pyx":63 + /* "_cdec.pyx":65 * * def __dealloc__(self): * del self.dec # <<<<<<<<<<<<<< @@ -17559,7 +18414,7 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_7weights_1__get__(PyObject *__pyx_v_se return __pyx_r; } -/* "_cdec.pyx":66 +/* "_cdec.pyx":68 * * property weights: * def __get__(self): # <<<<<<<<<<<<<< @@ -17572,7 +18427,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_7weights___get__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); - /* "_cdec.pyx":67 + /* "_cdec.pyx":69 * property weights: * def __get__(self): * return self.weights # <<<<<<<<<<<<<< @@ -17602,7 +18457,7 @@ static int __pyx_pw_5_cdec_7Decoder_7weights_3__set__(PyObject *__pyx_v_self, Py return __pyx_r; } -/* "_cdec.pyx":69 +/* "_cdec.pyx":71 * return self.weights * * def __set__(self, weights): # <<<<<<<<<<<<<< @@ -17629,7 +18484,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":70 + /* "_cdec.pyx":72 * * def __set__(self, weights): * if isinstance(weights, DenseVector): # <<<<<<<<<<<<<< @@ -17642,7 +18497,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":71 + /* "_cdec.pyx":73 * def __set__(self, weights): * if isinstance(weights, DenseVector): * self.weights.vector[0] = (<DenseVector> weights).vector[0] # <<<<<<<<<<<<<< @@ -17653,7 +18508,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De goto __pyx_L3; } - /* "_cdec.pyx":72 + /* "_cdec.pyx":74 * if isinstance(weights, DenseVector): * self.weights.vector[0] = (<DenseVector> weights).vector[0] * elif isinstance(weights, SparseVector): # <<<<<<<<<<<<<< @@ -17666,7 +18521,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":73 + /* "_cdec.pyx":75 * self.weights.vector[0] = (<DenseVector> weights).vector[0] * elif isinstance(weights, SparseVector): * self.weights.vector.clear() # <<<<<<<<<<<<<< @@ -17675,7 +18530,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De */ __pyx_v_self->weights->vector->clear(); - /* "_cdec.pyx":74 + /* "_cdec.pyx":76 * elif isinstance(weights, SparseVector): * self.weights.vector.clear() * ((<SparseVector> weights).vector[0]).init_vector(self.weights.vector) # <<<<<<<<<<<<<< @@ -17686,7 +18541,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De goto __pyx_L3; } - /* "_cdec.pyx":75 + /* "_cdec.pyx":77 * self.weights.vector.clear() * ((<SparseVector> weights).vector[0]).init_vector(self.weights.vector) * elif isinstance(weights, dict): # <<<<<<<<<<<<<< @@ -17699,7 +18554,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":76 + /* "_cdec.pyx":78 * ((<SparseVector> weights).vector[0]).init_vector(self.weights.vector) * elif isinstance(weights, dict): * self.weights.vector.clear() # <<<<<<<<<<<<<< @@ -17708,23 +18563,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":77 + /* "_cdec.pyx":79 * 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 = 77; __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 = 79; __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 = 77; __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 = 79; __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 = 77; __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 = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; } @@ -17733,23 +18588,23 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De 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++; + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 79; __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++; + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #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;}; + __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 = 79; __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 = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -17765,7 +18620,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De 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;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -17778,14 +18633,14 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De __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;} + __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __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 = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } 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 = 77; __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 = 79; __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; @@ -17793,7 +18648,7 @@ 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 = 77; __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 = 79; __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; @@ -17801,7 +18656,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __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_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L7_unpacking_done:; } __Pyx_XDECREF(__pyx_v_fname); @@ -17811,40 +18666,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":78 + /* "_cdec.pyx":80 * 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 = 78; __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 = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L3; } /*else*/ { - /* "_cdec.pyx":80 + /* "_cdec.pyx":82 * 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 = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_48), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __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[0]; __pyx_lineno = 80; __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 = 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[0]; __pyx_lineno = 80; __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 = 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[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; @@ -17876,12 +18731,12 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_9formalism_1__get__(PyObject *__pyx_v_ return __pyx_r; } -/* "_cdec.pyx":83 +/* "_cdec.pyx":85 * * property formalism: * def __get__(self): # <<<<<<<<<<<<<< * cdef variables_map* conf = &self.dec.GetConf() - * return conf[0]['formalism'].as_str() + * return str(conf[0]['formalism'].as_str().c_str()) */ static PyObject *__pyx_pf_5_cdec_7Decoder_9formalism___get__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self) { @@ -17889,31 +18744,40 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_9formalism___get__(struct __pyx_obj_5_ PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "_cdec.pyx":84 + /* "_cdec.pyx":86 * property formalism: * def __get__(self): * cdef variables_map* conf = &self.dec.GetConf() # <<<<<<<<<<<<<< - * return conf[0]['formalism'].as_str() + * return str(conf[0]['formalism'].as_str().c_str()) * */ __pyx_v_conf = (&__pyx_v_self->dec->GetConf()); - /* "_cdec.pyx":85 + /* "_cdec.pyx":87 * def __get__(self): * cdef variables_map* conf = &self.dec.GetConf() - * return conf[0]['formalism'].as_str() # <<<<<<<<<<<<<< + * return str(conf[0]['formalism'].as_str().c_str()) # <<<<<<<<<<<<<< * * def read_weights(self, weights): */ __Pyx_XDECREF(__pyx_r); - __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_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 = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_r = ((PyObject *)__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __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*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __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; __pyx_t_1 = 0; goto __pyx_L0; @@ -17921,6 +18785,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_9formalism___get__(struct __pyx_obj_5_ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("_cdec.Decoder.formalism.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -17931,6 +18796,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_9formalism___get__(struct __pyx_obj_5_ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_7Decoder_5read_weights(PyObject *__pyx_v_self, PyObject *__pyx_v_weights); /*proto*/ +static char __pyx_doc_5_cdec_7Decoder_4read_weights[] = "decoder.read_weights(filename): Read decoder weights from a file."; static PyObject *__pyx_pw_5_cdec_7Decoder_5read_weights(PyObject *__pyx_v_self, PyObject *__pyx_v_weights) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -17940,12 +18806,12 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_5read_weights(PyObject *__pyx_v_self, return __pyx_r; } -/* "_cdec.pyx":87 - * return conf[0]['formalism'].as_str() +/* "_cdec.pyx":89 + * return str(conf[0]['formalism'].as_str().c_str()) * * def read_weights(self, weights): # <<<<<<<<<<<<<< + * """decoder.read_weights(filename): Read decoder weights from a file.""" * with open(weights) as fp: - * for line in fp: */ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_weights) { @@ -17976,27 +18842,27 @@ 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":88 - * + /* "_cdec.pyx":91 * def read_weights(self, weights): + * """decoder.read_weights(filename): Read decoder weights from a file.""" * with open(weights) as fp: # <<<<<<<<<<<<<< * for line in fp: * if line.strip().startswith('#'): continue */ /*with:*/ { - __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_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __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 = 88; __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 = 91; __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 = 88; __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 = 91; __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 = 88; __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 = 91; __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 = 88; __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 = 91; __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; @@ -18011,8 +18877,8 @@ 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":89 - * def read_weights(self, weights): + /* "_cdec.pyx":92 + * """decoder.read_weights(filename): Read decoder weights from a file.""" * with open(weights) as fp: * for line in fp: # <<<<<<<<<<<<<< * if line.strip().startswith('#'): continue @@ -18022,7 +18888,7 @@ 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 = 89; __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 = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext; } @@ -18030,23 +18896,23 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ 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++; + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;} #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;}; + __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 = 92; __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++; + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;} #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;}; + __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 = 92; __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 = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;} } break; } @@ -18056,25 +18922,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":90 + /* "_cdec.pyx":93 * 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 = 90; __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 = 93; __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 = 90; __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 = 93; __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 = 90; __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 = 93; __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 = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_50), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __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 = 90; __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 = 93; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_10) { goto __pyx_L16_continue; @@ -18082,16 +18948,16 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ } __pyx_L18:; - /* "_cdec.pyx":91 + /* "_cdec.pyx":94 * 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 = 91; __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 = 94; __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 = 91; __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 = 94; __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))) { @@ -18104,7 +18970,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ 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;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L7_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -18117,14 +18983,14 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ __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;} + __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __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 = 94; __pyx_clineno = __LINE__; goto __pyx_L7_error;} #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } 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 = 91; __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 = 94; __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; @@ -18132,7 +18998,7 @@ 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 = 91; __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 = 94; __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; @@ -18140,7 +19006,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __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_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __pyx_L20_unpacking_done:; } __Pyx_XDECREF(__pyx_v_fname); @@ -18150,22 +19016,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":92 + /* "_cdec.pyx":95 * 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 = 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_t_14 = __Pyx_PyObject_AsDouble(__pyx_v_value); if (unlikely(__pyx_t_14 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __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 = 95; __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 = 92; __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 = 95; __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 = 92; __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 = 95; __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 = 92; __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 = 95; __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:; @@ -18183,20 +19049,20 @@ 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":88 - * + /* "_cdec.pyx":91 * def read_weights(self, weights): + * """decoder.read_weights(filename): Read decoder weights from a file.""" * with open(weights) as fp: # <<<<<<<<<<<<<< * for line in fp: * if line.strip().startswith('#'): continue */ /*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 = 88; __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 = 91; __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 = 88; __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 = 91; __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); @@ -18209,11 +19075,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 = 88; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} + if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __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 = 88; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} + if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} __pyx_t_16 = (!__pyx_t_10); if (__pyx_t_16) { __Pyx_GIVEREF(__pyx_t_4); @@ -18221,7 +19087,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 = 88; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} goto __pyx_L23; } __pyx_L23:; @@ -18247,13 +19113,13 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ } /*finally:*/ { if (__pyx_t_3) { - __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_52, NULL); + __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_51, NULL); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __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 = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } goto __pyx_L24; @@ -18285,6 +19151,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_7Decoder_6translate[] = "decoder.translate(sentence, grammar=None) -> Hypergraph\n Translate a sentence (string/Lattice) with a grammar (string/list of rules)."; 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; @@ -18295,12 +19162,12 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyO static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__sentence,&__pyx_n_s__grammar,0}; PyObject* values[2] = {0,0}; - /* "_cdec.pyx":94 + /* "_cdec.pyx":97 * self.weights[fname.strip()] = float(value) * * def translate(self, sentence, grammar=None): # <<<<<<<<<<<<<< - * cdef bytes input_str - * if isinstance(sentence, unicode) or isinstance(sentence, str): + * """decoder.translate(sentence, grammar=None) -> Hypergraph + * Translate a sentence (string/Lattice) with a grammar (string/list of rules).""" */ values[1] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { @@ -18324,7 +19191,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 = 94; __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 = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -18339,7 +19206,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 = 94; __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 = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.Decoder.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -18358,59 +19225,48 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - char *__pyx_t_6; + PyObject *__pyx_t_3 = NULL; + std::string __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("translate", 0); - /* "_cdec.pyx":96 - * def translate(self, sentence, grammar=None): + /* "_cdec.pyx":101 + * Translate a sentence (string/Lattice) with a grammar (string/list of rules).""" * cdef bytes input_str - * if isinstance(sentence, unicode) or isinstance(sentence, str): # <<<<<<<<<<<<<< + * if isinstance(sentence, basestring): # <<<<<<<<<<<<<< * input_str = as_str(sentence.strip()) * elif isinstance(sentence, Lattice): */ - __pyx_t_1 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); + __pyx_t_1 = __pyx_builtin_basestring; __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_sentence, __pyx_t_1); + __pyx_t_2 = PyObject_IsInstance(__pyx_v_sentence, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (!__pyx_t_2) { - __pyx_t_1 = ((PyObject *)((PyObject*)(&PyString_Type))); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_sentence, __pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_4 = __pyx_t_3; - } else { - __pyx_t_4 = __pyx_t_2; - } - if (__pyx_t_4) { + if (__pyx_t_2) { - /* "_cdec.pyx":97 + /* "_cdec.pyx":102 * cdef bytes input_str - * if isinstance(sentence, unicode) or isinstance(sentence, str): + * if isinstance(sentence, basestring): * 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 = 97; __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 = 102; __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 = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __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 = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __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 = 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; + __pyx_t_1 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_t_3, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_input_str = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L3; } - /* "_cdec.pyx":98 - * if isinstance(sentence, unicode) or isinstance(sentence, str): + /* "_cdec.pyx":103 + * if isinstance(sentence, basestring): * input_str = as_str(sentence.strip()) * elif isinstance(sentence, Lattice): # <<<<<<<<<<<<<< * input_str = str(sentence) # PLF format @@ -18418,114 +19274,109 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec */ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Lattice)); __Pyx_INCREF(__pyx_t_1); - __pyx_t_4 = __Pyx_TypeCheck(__pyx_v_sentence, __pyx_t_1); + __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_sentence, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_4) { + if (__pyx_t_2) { - /* "_cdec.pyx":99 + /* "_cdec.pyx":104 * 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 = 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 = 104; __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 = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __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 = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_input_str = ((PyObject*)__pyx_t_5); - __pyx_t_5 = 0; + if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_input_str = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; goto __pyx_L3; } /*else*/ { - /* "_cdec.pyx":101 + /* "_cdec.pyx":106 * 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): + * if isinstance(grammar, basestring): */ - __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 = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_52), ((PyObject *)Py_TYPE(__pyx_v_sentence))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + __pyx_t_1 = PyTuple_New(1); 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); - 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 = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3)); + __Pyx_GIVEREF(((PyObject *)__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 = 106; __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_5, 0, 0, 0); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; - /* "_cdec.pyx":102 + /* "_cdec.pyx":107 * 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))) + * if isinstance(grammar, basestring): + * self.dec.AddSupplementalGrammarFromString(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 = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_grammar); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_2) { - /* "_cdec.pyx":103 + /* "_cdec.pyx":108 * 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))) + * if isinstance(grammar, basestring): # <<<<<<<<<<<<<< + * self.dec.AddSupplementalGrammarFromString(as_str(grammar)) * else: */ - __pyx_t_5 = ((PyObject *)((PyObject*)(&PyString_Type))); - __Pyx_INCREF(__pyx_t_5); - __pyx_t_4 = __Pyx_TypeCheck(__pyx_v_grammar, __pyx_t_5); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (!__pyx_t_4) { - __pyx_t_5 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); - __Pyx_INCREF(__pyx_t_5); - __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_grammar, __pyx_t_5); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_3 = __pyx_t_2; - } else { - __pyx_t_3 = __pyx_t_4; - } - if (__pyx_t_3) { + __pyx_t_3 = __pyx_builtin_basestring; + __Pyx_INCREF(__pyx_t_3); + __pyx_t_2 = PyObject_IsInstance(__pyx_v_grammar, __pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_2) { - /* "_cdec.pyx":104 + /* "_cdec.pyx":109 * if grammar: - * if isinstance(grammar, str) or isinstance(grammar, unicode): - * self.dec.AddSupplementalGrammarFromString(string(as_str(grammar))) # <<<<<<<<<<<<<< + * if isinstance(grammar, basestring): + * self.dec.AddSupplementalGrammarFromString(as_str(grammar)) # <<<<<<<<<<<<<< * else: * self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0]) */ - __pyx_v_self->dec->AddSupplementalGrammarFromString(std::string(__pyx_f_5_cdec_as_str(__pyx_v_grammar, NULL))); + __pyx_t_3 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_v_grammar, NULL)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __pyx_convert_string_from_py_(__pyx_t_3); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_self->dec->AddSupplementalGrammarFromString(__pyx_t_4); goto __pyx_L5; } /*else*/ { - /* "_cdec.pyx":106 - * self.dec.AddSupplementalGrammarFromString(string(as_str(grammar))) + /* "_cdec.pyx":111 + * self.dec.AddSupplementalGrammarFromString(as_str(grammar)) * else: * self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0]) # <<<<<<<<<<<<<< * cdef decoder.BasicObserver observer = decoder.BasicObserver() - * self.dec.Decode(string(input_str), &observer) + * self.dec.Decode(input_str, &observer) */ - __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_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_grammar); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_grammar); + PyTuple_SET_ITEM(__pyx_t_3, 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 = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TextGrammar)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __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_3)); __pyx_t_3 = 0; __pyx_v_self->dec->AddSupplementalGrammar((((struct __pyx_obj_5_cdec_TextGrammar *)__pyx_t_1)->__pyx_base.grammar[0])); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } @@ -18534,67 +19385,67 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec } __pyx_L4:; - /* "_cdec.pyx":107 + /* "_cdec.pyx":112 * else: * self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0]) * cdef decoder.BasicObserver observer = decoder.BasicObserver() # <<<<<<<<<<<<<< - * self.dec.Decode(string(input_str), &observer) + * self.dec.Decode(input_str, &observer) * if observer.hypergraph == NULL: */ __pyx_v_observer = BasicObserver(); - /* "_cdec.pyx":108 + /* "_cdec.pyx":113 * self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0]) * cdef decoder.BasicObserver observer = decoder.BasicObserver() - * self.dec.Decode(string(input_str), &observer) # <<<<<<<<<<<<<< + * self.dec.Decode(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 = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->dec->Decode(std::string(__pyx_t_6), (&__pyx_v_observer)); + __pyx_t_4 = __pyx_convert_string_from_py_(((PyObject *)__pyx_v_input_str)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->dec->Decode(__pyx_t_4, (&__pyx_v_observer)); - /* "_cdec.pyx":109 + /* "_cdec.pyx":114 * cdef decoder.BasicObserver observer = decoder.BasicObserver() - * self.dec.Decode(string(input_str), &observer) + * self.dec.Decode(input_str, &observer) * if observer.hypergraph == NULL: # <<<<<<<<<<<<<< * raise ParseFailed() * cdef Hypergraph hg = Hypergraph() */ - __pyx_t_3 = (__pyx_v_observer.hypergraph == NULL); - if (__pyx_t_3) { + __pyx_t_2 = (__pyx_v_observer.hypergraph == NULL); + if (__pyx_t_2) { - /* "_cdec.pyx":110 - * self.dec.Decode(string(input_str), &observer) + /* "_cdec.pyx":115 + * self.dec.Decode(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 = 110; __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 = 115; __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 = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __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 = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __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 = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L6; } __pyx_L6:; - /* "_cdec.pyx":111 + /* "_cdec.pyx":116 * 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 = 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; + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Hypergraph)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_v_hg = ((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_t_3); + __pyx_t_3 = 0; - /* "_cdec.pyx":112 + /* "_cdec.pyx":117 * raise ParseFailed() * cdef Hypergraph hg = Hypergraph() * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0]) # <<<<<<<<<<<<<< @@ -18602,7 +19453,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":113 + /* "_cdec.pyx":118 * cdef Hypergraph hg = Hypergraph() * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0]) * return hg # <<<<<<<<<<<<<< @@ -18616,7 +19467,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("_cdec.Decoder.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -18627,45 +19478,40 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec return __pyx_r; } -/* "string.to_py":25 +/* "string.from_py":11 * - * @cname("__pyx_convert_string_to_py_") - * cdef object __pyx_convert_string_to_py_(string& s): # <<<<<<<<<<<<<< - * return s.data()[:s.size()] + * @cname("__pyx_convert_string_from_py_") + * cdef string __pyx_convert_string_from_py_(object o) except *: # <<<<<<<<<<<<<< + * return string(<char*>o, len(o)) * */ -static PyObject *__pyx_convert_string_to_py_(const std::string &__pyx_v_s) { - PyObject *__pyx_r = NULL; +static std::string __pyx_convert_string_from_py_(PyObject *__pyx_v_o) { + std::string __pyx_r; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; + char *__pyx_t_1; + Py_ssize_t __pyx_t_2; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__pyx_convert_string_to_py_", 0); + __Pyx_RefNannySetupContext("__pyx_convert_string_from_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()] # <<<<<<<<<<<<<< + /* "string.from_py":12 + * @cname("__pyx_convert_string_from_py_") + * cdef string __pyx_convert_string_from_py_(object o) except *: + * return string(<char*>o, len(o)) # <<<<<<<<<<<<<< * * */ - __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; + __pyx_t_1 = PyBytes_AsString(__pyx_v_o); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = std::string(((char *)__pyx_t_1), __pyx_t_2); 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_AddTraceback("string.from_py.__pyx_convert_string_from_py_", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -18708,8 +19554,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_14dot, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("tosparse"), (PyCFunction)__pyx_pw_5_cdec_11DenseVector_16tosparse, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("dot"), (PyCFunction)__pyx_pw_5_cdec_11DenseVector_14dot, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_11DenseVector_13dot)}, + {__Pyx_NAMESTR("tosparse"), (PyCFunction)__pyx_pw_5_cdec_11DenseVector_16tosparse, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_11DenseVector_15tosparse)}, {0, 0, 0, 0} }; @@ -18905,8 +19751,8 @@ 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_5copy, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("dot"), (PyCFunction)__pyx_pw_5_cdec_12SparseVector_14dot, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("copy"), (PyCFunction)__pyx_pw_5_cdec_12SparseVector_5copy, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_12SparseVector_4copy)}, + {__Pyx_NAMESTR("dot"), (PyCFunction)__pyx_pw_5_cdec_12SparseVector_14dot, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_12SparseVector_13dot)}, {0, 0, 0, 0} }; @@ -19075,7 +19921,7 @@ static PyObject *__pyx_tp_new_5_cdec_NT(PyTypeObject *t, CYTHON_UNUSED PyObject static void __pyx_tp_dealloc_5_cdec_NT(PyObject *o) { struct __pyx_obj_5_cdec_NT *p = (struct __pyx_obj_5_cdec_NT *)o; - Py_XDECREF(((PyObject *)p->cat)); + Py_CLEAR(p->cat); (*Py_TYPE(o)->tp_free)(o); } @@ -20103,9 +20949,6 @@ static PyTypeObject __pyx_type_5_cdec_Grammar = { static PyObject *__pyx_tp_new_5_cdec_TextGrammar(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = __pyx_tp_new_5_cdec_Grammar(t, a, k); if (!o) return 0; - if (__pyx_pw_5_cdec_11TextGrammar_1__cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } return o; } @@ -20255,7 +21098,7 @@ static PyTypeObject __pyx_type_5_cdec_TextGrammar = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - 0, /*tp_init*/ + __pyx_pw_5_cdec_11TextGrammar_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_5_cdec_TextGrammar, /*tp_new*/ 0, /*tp_free*/ @@ -20270,10 +21113,14 @@ static PyTypeObject __pyx_type_5_cdec_TextGrammar = { 0, /*tp_version_tag*/ #endif }; +static struct __pyx_vtabstruct_5_cdec_Hypergraph __pyx_vtable_5_cdec_Hypergraph; static PyObject *__pyx_tp_new_5_cdec_Hypergraph(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_5_cdec_Hypergraph *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; + p = ((struct __pyx_obj_5_cdec_Hypergraph *)o); + p->__pyx_vtab = __pyx_vtabptr_5_cdec_Hypergraph; return o; } @@ -20307,19 +21154,21 @@ static PyObject *__pyx_getprop_5_cdec_10Hypergraph_npaths(PyObject *o, CYTHON_UN } static PyMethodDef __pyx_methods_5_cdec_Hypergraph[] = { - {__Pyx_NAMESTR("viterbi"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_3viterbi, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("viterbi_trees"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_5viterbi_trees, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("viterbi_features"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_7viterbi_features, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("viterbi_joshua"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_9viterbi_joshua, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("kbest"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_11kbest, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("kbest_trees"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_14kbest_trees, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("kbest_features"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_17kbest_features, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_20sample, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("intersect"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_23intersect, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("prune"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_25prune, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("lattice"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_27lattice, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("reweight"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_29reweight, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("inside_outside"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_31inside_outside, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("viterbi"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_3viterbi, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_2viterbi)}, + {__Pyx_NAMESTR("viterbi_trees"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_5viterbi_trees, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_4viterbi_trees)}, + {__Pyx_NAMESTR("viterbi_features"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_7viterbi_features, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_6viterbi_features)}, + {__Pyx_NAMESTR("viterbi_joshua"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_9viterbi_joshua, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_8viterbi_joshua)}, + {__Pyx_NAMESTR("kbest"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_11kbest, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_10kbest)}, + {__Pyx_NAMESTR("kbest_trees"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_14kbest_trees, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_13kbest_trees)}, + {__Pyx_NAMESTR("kbest_features"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_17kbest_features, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_16kbest_features)}, + {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_20sample, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_19sample)}, + {__Pyx_NAMESTR("sample_trees"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_23sample_trees, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_22sample_trees)}, + {__Pyx_NAMESTR("intersect"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_26intersect, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_25intersect)}, + {__Pyx_NAMESTR("prune"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_28prune, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_27prune)}, + {__Pyx_NAMESTR("lattice"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_30lattice, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_29lattice)}, + {__Pyx_NAMESTR("plf"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_32plf, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_31plf)}, + {__Pyx_NAMESTR("reweight"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_34reweight, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_33reweight)}, + {__Pyx_NAMESTR("inside_outside"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_36inside_outside, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_35inside_outside)}, {0, 0, 0, 0} }; @@ -20498,7 +21347,7 @@ static PyObject *__pyx_tp_new_5_cdec_HypergraphEdge(PyTypeObject *t, CYTHON_UNUS static void __pyx_tp_dealloc_5_cdec_HypergraphEdge(PyObject *o) { struct __pyx_obj_5_cdec_HypergraphEdge *p = (struct __pyx_obj_5_cdec_HypergraphEdge *)o; - Py_XDECREF(((PyObject *)p->trule)); + Py_CLEAR(p->trule); (*Py_TYPE(o)->tp_free)(o); } @@ -20917,10 +21766,10 @@ static PyTypeObject __pyx_type_5_cdec_HypergraphNode = { #endif }; -static PyObject *__pyx_tp_new_5_cdec_Lattice(PyTypeObject *t, PyObject *a, PyObject *k) { +static PyObject *__pyx_tp_new_5_cdec_Lattice(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - if (__pyx_pw_5_cdec_7Lattice_1__cinit__(o, a, k) < 0) { + if (__pyx_pw_5_cdec_7Lattice_1__cinit__(o, __pyx_empty_tuple, NULL) < 0) { Py_DECREF(o); o = 0; } return o; @@ -20931,7 +21780,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_3__dealloc__(o); + __pyx_pw_5_cdec_7Lattice_5__dealloc__(o); if (PyErr_Occurred()) PyErr_WriteUnraisable(o); --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); @@ -20948,7 +21797,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_7__setitem__(o, i, v); + return __pyx_pw_5_cdec_7Lattice_9__setitem__(o, i, v); } else { PyErr_Format(PyExc_NotImplementedError, @@ -20958,7 +21807,9 @@ static int __pyx_mp_ass_subscript_5_cdec_Lattice(PyObject *o, PyObject *i, PyObj } static PyMethodDef __pyx_methods_5_cdec_Lattice[] = { - {__Pyx_NAMESTR("todot"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_16todot, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__unicode__"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_15__unicode__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("todot"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_20todot, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_7Lattice_19todot)}, + {__Pyx_NAMESTR("as_hypergraph"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_22as_hypergraph, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_7Lattice_21as_hypergraph)}, {0, 0, 0, 0} }; @@ -21021,7 +21872,7 @@ static PyNumberMethods __pyx_tp_as_number_Lattice = { }; static PySequenceMethods __pyx_tp_as_sequence_Lattice = { - __pyx_pw_5_cdec_7Lattice_9__len__, /*sq_length*/ + __pyx_pw_5_cdec_7Lattice_11__len__, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ __pyx_sq_item_5_cdec_Lattice, /*sq_item*/ @@ -21034,8 +21885,8 @@ static PySequenceMethods __pyx_tp_as_sequence_Lattice = { }; static PyMappingMethods __pyx_tp_as_mapping_Lattice = { - __pyx_pw_5_cdec_7Lattice_9__len__, /*mp_length*/ - __pyx_pw_5_cdec_7Lattice_5__getitem__, /*mp_subscript*/ + __pyx_pw_5_cdec_7Lattice_11__len__, /*mp_length*/ + __pyx_pw_5_cdec_7Lattice_7__getitem__, /*mp_subscript*/ __pyx_mp_ass_subscript_5_cdec_Lattice, /*mp_ass_subscript*/ }; @@ -21080,7 +21931,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_11__str__, /*tp_str*/ + __pyx_pw_5_cdec_7Lattice_13__str__, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_Lattice, /*tp_as_buffer*/ @@ -21090,7 +21941,7 @@ static PyTypeObject __pyx_type_5_cdec_Lattice = { 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ - __pyx_pw_5_cdec_7Lattice_13__iter__, /*tp_iter*/ + __pyx_pw_5_cdec_7Lattice_17__iter__, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_5_cdec_Lattice, /*tp_methods*/ 0, /*tp_members*/ @@ -21100,7 +21951,7 @@ static PyTypeObject __pyx_type_5_cdec_Lattice = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - 0, /*tp_init*/ + __pyx_pw_5_cdec_7Lattice_3__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_5_cdec_Lattice, /*tp_new*/ 0, /*tp_free*/ @@ -21541,7 +22392,7 @@ static PyObject *__pyx_sq_item_5_cdec_CandidateSet(PyObject *o, Py_ssize_t i) { } static PyMethodDef __pyx_methods_5_cdec_CandidateSet[] = { - {__Pyx_NAMESTR("add_kbest"), (PyCFunction)__pyx_pw_5_cdec_12CandidateSet_12add_kbest, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("add_kbest"), (PyCFunction)__pyx_pw_5_cdec_12CandidateSet_12add_kbest, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5_cdec_12CandidateSet_11add_kbest)}, {0, 0, 0, 0} }; @@ -21719,8 +22570,8 @@ static void __pyx_tp_dealloc_5_cdec_SegmentEvaluator(PyObject *o) { } static PyMethodDef __pyx_methods_5_cdec_SegmentEvaluator[] = { - {__Pyx_NAMESTR("evaluate"), (PyCFunction)__pyx_pw_5_cdec_16SegmentEvaluator_3evaluate, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("candidate_set"), (PyCFunction)__pyx_pw_5_cdec_16SegmentEvaluator_5candidate_set, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("evaluate"), (PyCFunction)__pyx_pw_5_cdec_16SegmentEvaluator_3evaluate, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_16SegmentEvaluator_2evaluate)}, + {__Pyx_NAMESTR("candidate_set"), (PyCFunction)__pyx_pw_5_cdec_16SegmentEvaluator_5candidate_set, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_16SegmentEvaluator_4candidate_set)}, {0, 0, 0, 0} }; @@ -22072,7 +22923,7 @@ static PyObject *__pyx_tp_new_5_cdec_Metric(PyTypeObject *t, CYTHON_UNUSED PyObj static void __pyx_tp_dealloc_5_cdec_Metric(PyObject *o) { struct __pyx_obj_5_cdec_Metric *p = (struct __pyx_obj_5_cdec_Metric *)o; - Py_XDECREF(((PyObject *)p->scorer)); + Py_CLEAR(p->scorer); (*Py_TYPE(o)->tp_free)(o); } @@ -22254,15 +23105,12 @@ static PyTypeObject __pyx_type_5_cdec_Metric = { #endif }; -static PyObject *__pyx_tp_new_5_cdec_Decoder(PyTypeObject *t, PyObject *a, PyObject *k) { +static PyObject *__pyx_tp_new_5_cdec_Decoder(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_5_cdec_Decoder *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; p = ((struct __pyx_obj_5_cdec_Decoder *)o); p->weights = ((struct __pyx_obj_5_cdec_DenseVector *)Py_None); Py_INCREF(Py_None); - if (__pyx_pw_5_cdec_7Decoder_1__cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } return o; } @@ -22277,7 +23125,7 @@ static void __pyx_tp_dealloc_5_cdec_Decoder(PyObject *o) { --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } - Py_XDECREF(((PyObject *)p->weights)); + Py_CLEAR(p->weights); (*Py_TYPE(o)->tp_free)(o); } @@ -22318,8 +23166,8 @@ static PyObject *__pyx_getprop_5_cdec_7Decoder_formalism(PyObject *o, CYTHON_UNU } static PyMethodDef __pyx_methods_5_cdec_Decoder[] = { - {__Pyx_NAMESTR("read_weights"), (PyCFunction)__pyx_pw_5_cdec_7Decoder_5read_weights, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("translate"), (PyCFunction)__pyx_pw_5_cdec_7Decoder_7translate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("read_weights"), (PyCFunction)__pyx_pw_5_cdec_7Decoder_5read_weights, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_7Decoder_4read_weights)}, + {__Pyx_NAMESTR("translate"), (PyCFunction)__pyx_pw_5_cdec_7Decoder_7translate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5_cdec_7Decoder_6translate)}, {0, 0, 0, 0} }; @@ -22467,7 +23315,7 @@ static PyTypeObject __pyx_type_5_cdec_Decoder = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - 0, /*tp_init*/ + __pyx_pw_5_cdec_7Decoder_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_5_cdec_Decoder, /*tp_new*/ 0, /*tp_free*/ @@ -22494,7 +23342,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct____iter__(PyTypeObject * static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct____iter__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -22685,7 +23533,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_1___iter__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_1___iter__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -22876,7 +23724,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_2__phrase(PyTypeObject * static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_2__phrase(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *)o; - Py_XDECREF(p->__pyx_v_phrase); + Py_CLEAR(p->__pyx_v_phrase); (*Py_TYPE(o)->tp_free)(o); } @@ -23069,9 +23917,9 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_3_genexpr(PyTypeObject * static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_3_genexpr(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr *)o; - Py_XDECREF(((PyObject *)p->__pyx_outer_scope)); - Py_XDECREF(p->__pyx_v_w); - Py_XDECREF(p->__pyx_t_0); + Py_CLEAR(p->__pyx_outer_scope); + Py_CLEAR(p->__pyx_v_w); + Py_CLEAR(p->__pyx_t_0); (*Py_TYPE(o)->tp_free)(o); } @@ -23274,7 +24122,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_4___get__(PyTypeObject * static void __pyx_tp_dealloc_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; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -23465,7 +24313,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_5___str__(PyTypeObject * static void __pyx_tp_dealloc_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; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -23658,9 +24506,9 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_6_genexpr(PyTypeObject * static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_6_genexpr(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *)o; - Py_XDECREF(((PyObject *)p->__pyx_outer_scope)); - Py_XDECREF(p->__pyx_v_feat); - Py_XDECREF(p->__pyx_t_0); + Py_CLEAR(p->__pyx_outer_scope); + Py_CLEAR(p->__pyx_v_feat); + Py_CLEAR(p->__pyx_t_0); (*Py_TYPE(o)->tp_free)(o); } @@ -23864,8 +24712,8 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_7___iter__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_7___iter__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); - Py_XDECREF(((PyObject *)p->__pyx_v_trule)); + Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_v_trule); (*Py_TYPE(o)->tp_free)(o); } @@ -24063,8 +24911,8 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_8_kbest(PyTypeObject *t, static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_8_kbest(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); - Py_XDECREF(p->__pyx_v_size); + Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_v_size); (*Py_TYPE(o)->tp_free)(o); } @@ -24264,10 +25112,10 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_9_kbest_trees(PyTypeObje static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_9_kbest_trees(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_e_tree)); - Py_XDECREF(((PyObject *)p->__pyx_v_f_tree)); - Py_XDECREF(((PyObject *)p->__pyx_v_self)); - Py_XDECREF(p->__pyx_v_size); + Py_CLEAR(p->__pyx_v_e_tree); + Py_CLEAR(p->__pyx_v_f_tree); + Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_v_size); (*Py_TYPE(o)->tp_free)(o); } @@ -24478,9 +25326,9 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_10_kbest_features(PyType static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_10_kbest_features(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_fmap)); - Py_XDECREF(((PyObject *)p->__pyx_v_self)); - Py_XDECREF(p->__pyx_v_size); + Py_CLEAR(p->__pyx_v_fmap); + Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_v_size); (*Py_TYPE(o)->tp_free)(o); } @@ -24683,7 +25531,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_11_sample(PyTypeObject * static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_11_sample(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -24863,32 +25711,32 @@ 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, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *p; +static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_12_sample_trees(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *)o); + p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *)o); p->__pyx_v_self = 0; return o; } -static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_12___get__(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); +static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_12_sample_trees(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *)o; + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_12___get__(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_12_sample_trees(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *)o; + struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *)o; if (p->__pyx_v_self) { e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; } return 0; } -static int __pyx_tp_clear_5_cdec___pyx_scope_struct_12___get__(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *)o; +static int __pyx_tp_clear_5_cdec___pyx_scope_struct_12_sample_trees(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_v_self); p->__pyx_v_self = ((struct __pyx_obj_5_cdec_Hypergraph *)Py_None); Py_INCREF(Py_None); @@ -24896,11 +25744,11 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_12___get__(PyObject *o) { return 0; } -static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_12___get__[] = { +static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_12_sample_trees[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_12___get__ = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_12_sample_trees = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -24958,7 +25806,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_12___get__ = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_12___get__ = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_12_sample_trees = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -24971,13 +25819,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_12___get__ = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_12___get__ = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_12_sample_trees = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_12___get__ = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_12_sample_trees = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -24998,12 +25846,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_12___get__ = { #endif }; -static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_12___get__ = { +static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_12_sample_trees = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_cdec.__pyx_scope_struct_12___get__"), /*tp_name*/ - sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__), /*tp_basicsize*/ + __Pyx_NAMESTR("_cdec.__pyx_scope_struct_12_sample_trees"), /*tp_name*/ + sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5_cdec___pyx_scope_struct_12___get__, /*tp_dealloc*/ + __pyx_tp_dealloc_5_cdec___pyx_scope_struct_12_sample_trees, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -25013,24 +25861,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_12___get__ = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct_12___get__, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct_12___get__, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct_12___get__, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_12_sample_trees, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_12_sample_trees, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_12_sample_trees, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct_12___get__, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_12_sample_trees, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_5_cdec___pyx_scope_struct_12___get__, /*tp_traverse*/ - __pyx_tp_clear_5_cdec___pyx_scope_struct_12___get__, /*tp_clear*/ + __pyx_tp_traverse_5_cdec___pyx_scope_struct_12_sample_trees, /*tp_traverse*/ + __pyx_tp_clear_5_cdec___pyx_scope_struct_12_sample_trees, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_5_cdec___pyx_scope_struct_12___get__, /*tp_methods*/ + __pyx_methods_5_cdec___pyx_scope_struct_12_sample_trees, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -25040,7 +25888,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_12___get__ = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_5_cdec___pyx_scope_struct_12___get__, /*tp_new*/ + __pyx_tp_new_5_cdec___pyx_scope_struct_12_sample_trees, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -25065,7 +25913,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_13___get__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_13___get__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -25256,7 +26104,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_14___get__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_14___get__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -25273,7 +26121,7 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_14___get__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_v_self); - p->__pyx_v_self = ((struct __pyx_obj_5_cdec_HypergraphEdge *)Py_None); Py_INCREF(Py_None); + p->__pyx_v_self = ((struct __pyx_obj_5_cdec_Hypergraph *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } @@ -25447,7 +26295,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_15___get__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_15___get__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -25464,7 +26312,7 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_15___get__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_v_self); - p->__pyx_v_self = ((struct __pyx_obj_5_cdec_HypergraphNode *)Py_None); Py_INCREF(Py_None); + p->__pyx_v_self = ((struct __pyx_obj_5_cdec_HypergraphEdge *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } @@ -25638,7 +26486,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_16___get__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_16___get__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -25818,32 +26666,223 @@ 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, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *p; +static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_17___get__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *)o); + p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ *)o); p->__pyx_v_self = 0; return o; } -static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_17___iter__(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); +static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_17___get__(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ *)o; + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_17___iter__(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_17___get__(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *)o; + struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ *)o; if (p->__pyx_v_self) { e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; } return 0; } -static int __pyx_tp_clear_5_cdec___pyx_scope_struct_17___iter__(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *)o; +static int __pyx_tp_clear_5_cdec___pyx_scope_struct_17___get__(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ *)o; + PyObject* tmp; + tmp = ((PyObject*)p->__pyx_v_self); + p->__pyx_v_self = ((struct __pyx_obj_5_cdec_HypergraphNode *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_17___get__[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_17___get__ = { + 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___pyx_scope_struct_17___get__ = { + 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___pyx_scope_struct_17___get__ = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_17___get__ = { + #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___pyx_scope_struct_17___get__ = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("_cdec.__pyx_scope_struct_17___get__"), /*tp_name*/ + sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_5_cdec___pyx_scope_struct_17___get__, /*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___pyx_scope_struct_17___get__, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_17___get__, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_17___get__, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer___pyx_scope_struct_17___get__, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_5_cdec___pyx_scope_struct_17___get__, /*tp_traverse*/ + __pyx_tp_clear_5_cdec___pyx_scope_struct_17___get__, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_5_cdec___pyx_scope_struct_17___get__, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_5_cdec___pyx_scope_struct_17___get__, /*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___pyx_scope_struct_18___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *)o); + p->__pyx_v_self = 0; + return o; +} + +static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_18___iter__(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *)o; + Py_CLEAR(p->__pyx_v_self); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_18___iter__(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *)o; + if (p->__pyx_v_self) { + e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_5_cdec___pyx_scope_struct_18___iter__(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_v_self); p->__pyx_v_self = ((struct __pyx_obj_5_cdec_Lattice *)Py_None); Py_INCREF(Py_None); @@ -25851,11 +26890,11 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_17___iter__(PyObject *o) { return 0; } -static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_17___iter__[] = { +static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_18___iter__[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_17___iter__ = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_18___iter__ = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -25913,7 +26952,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_17___iter__ = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_17___iter__ = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_18___iter__ = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -25926,13 +26965,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_17___iter__ = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_17___iter__ = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_18___iter__ = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_17___iter__ = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_18___iter__ = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -25953,12 +26992,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_17___iter__ = { #endif }; -static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_17___iter__ = { +static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_18___iter__ = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_cdec.__pyx_scope_struct_17___iter__"), /*tp_name*/ - sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__), /*tp_basicsize*/ + __Pyx_NAMESTR("_cdec.__pyx_scope_struct_18___iter__"), /*tp_name*/ + sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5_cdec___pyx_scope_struct_17___iter__, /*tp_dealloc*/ + __pyx_tp_dealloc_5_cdec___pyx_scope_struct_18___iter__, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -25968,24 +27007,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_17___iter__ = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct_17___iter__, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct_17___iter__, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct_17___iter__, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_18___iter__, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_18___iter__, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_18___iter__, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct_17___iter__, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_18___iter__, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_5_cdec___pyx_scope_struct_17___iter__, /*tp_traverse*/ - __pyx_tp_clear_5_cdec___pyx_scope_struct_17___iter__, /*tp_clear*/ + __pyx_tp_traverse_5_cdec___pyx_scope_struct_18___iter__, /*tp_traverse*/ + __pyx_tp_clear_5_cdec___pyx_scope_struct_18___iter__, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_5_cdec___pyx_scope_struct_17___iter__, /*tp_methods*/ + __pyx_methods_5_cdec___pyx_scope_struct_18___iter__, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -25995,7 +27034,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_17___iter__ = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_5_cdec___pyx_scope_struct_17___iter__, /*tp_new*/ + __pyx_tp_new_5_cdec___pyx_scope_struct_18___iter__, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -26009,32 +27048,32 @@ 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, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *p; +static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_19_todot(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *)o); + p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *)o); p->__pyx_v_self = 0; return o; } -static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_18_todot(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); +static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_19_todot(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *)o; + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_18_todot(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_19_todot(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *)o; + struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *)o; if (p->__pyx_v_self) { e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; } return 0; } -static int __pyx_tp_clear_5_cdec___pyx_scope_struct_18_todot(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *)o; +static int __pyx_tp_clear_5_cdec___pyx_scope_struct_19_todot(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_v_self); p->__pyx_v_self = ((struct __pyx_obj_5_cdec_Lattice *)Py_None); Py_INCREF(Py_None); @@ -26042,11 +27081,11 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_18_todot(PyObject *o) { return 0; } -static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_18_todot[] = { +static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_19_todot[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_18_todot = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_19_todot = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -26104,7 +27143,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_18_todot = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_18_todot = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_19_todot = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -26117,13 +27156,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_18_todot = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_18_todot = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_19_todot = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_18_todot = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_19_todot = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -26144,12 +27183,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_18_todot = { #endif }; -static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_18_todot = { +static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_19_todot = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_cdec.__pyx_scope_struct_18_todot"), /*tp_name*/ - sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot), /*tp_basicsize*/ + __Pyx_NAMESTR("_cdec.__pyx_scope_struct_19_todot"), /*tp_name*/ + sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5_cdec___pyx_scope_struct_18_todot, /*tp_dealloc*/ + __pyx_tp_dealloc_5_cdec___pyx_scope_struct_19_todot, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -26159,24 +27198,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_18_todot = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct_18_todot, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct_18_todot, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct_18_todot, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_19_todot, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_19_todot, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_19_todot, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct_18_todot, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_19_todot, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_5_cdec___pyx_scope_struct_18_todot, /*tp_traverse*/ - __pyx_tp_clear_5_cdec___pyx_scope_struct_18_todot, /*tp_clear*/ + __pyx_tp_traverse_5_cdec___pyx_scope_struct_19_todot, /*tp_traverse*/ + __pyx_tp_clear_5_cdec___pyx_scope_struct_19_todot, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_5_cdec___pyx_scope_struct_18_todot, /*tp_methods*/ + __pyx_methods_5_cdec___pyx_scope_struct_19_todot, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -26186,7 +27225,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_18_todot = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_5_cdec___pyx_scope_struct_18_todot, /*tp_new*/ + __pyx_tp_new_5_cdec___pyx_scope_struct_19_todot, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -26200,11 +27239,11 @@ 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, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *p; +static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_20_lines(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *)o); + p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines *)o); p->__pyx_outer_scope = 0; p->__pyx_v_delta = 0; p->__pyx_v_i = 0; @@ -26215,21 +27254,21 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_19_lines(PyTypeObject *t return o; } -static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_19_lines(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *)o; - Py_XDECREF(((PyObject *)p->__pyx_outer_scope)); - Py_XDECREF(p->__pyx_v_delta); - Py_XDECREF(p->__pyx_v_i); - Py_XDECREF(p->__pyx_v_label); - Py_XDECREF(p->__pyx_v_weight); - Py_XDECREF(p->__pyx_t_1); - Py_XDECREF(p->__pyx_t_3); +static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_20_lines(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines *)o; + Py_CLEAR(p->__pyx_outer_scope); + Py_CLEAR(p->__pyx_v_delta); + Py_CLEAR(p->__pyx_v_i); + Py_CLEAR(p->__pyx_v_label); + Py_CLEAR(p->__pyx_v_weight); + Py_CLEAR(p->__pyx_t_1); + Py_CLEAR(p->__pyx_t_3); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_19_lines(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_20_lines(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *)o; + struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines *)o; if (p->__pyx_outer_scope) { e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e; } @@ -26254,11 +27293,11 @@ static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_19_lines(PyObject *o, vis return 0; } -static int __pyx_tp_clear_5_cdec___pyx_scope_struct_19_lines(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *)o; +static int __pyx_tp_clear_5_cdec___pyx_scope_struct_20_lines(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_outer_scope); - p->__pyx_outer_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *)Py_None); Py_INCREF(Py_None); + p->__pyx_outer_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_v_delta); p->__pyx_v_delta = Py_None; Py_INCREF(Py_None); @@ -26281,11 +27320,11 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_19_lines(PyObject *o) { return 0; } -static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_19_lines[] = { +static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_20_lines[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_19_lines = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_20_lines = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -26343,7 +27382,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_19_lines = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_19_lines = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_20_lines = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -26356,13 +27395,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_19_lines = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_19_lines = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_20_lines = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_19_lines = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_20_lines = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -26383,12 +27422,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_19_lines = { #endif }; -static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_19_lines = { +static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_20_lines = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_cdec.__pyx_scope_struct_19_lines"), /*tp_name*/ - sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines), /*tp_basicsize*/ + __Pyx_NAMESTR("_cdec.__pyx_scope_struct_20_lines"), /*tp_name*/ + sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5_cdec___pyx_scope_struct_19_lines, /*tp_dealloc*/ + __pyx_tp_dealloc_5_cdec___pyx_scope_struct_20_lines, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -26398,24 +27437,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_19_lines = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct_19_lines, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct_19_lines, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct_19_lines, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_20_lines, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_20_lines, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_20_lines, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct_19_lines, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_20_lines, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_5_cdec___pyx_scope_struct_19_lines, /*tp_traverse*/ - __pyx_tp_clear_5_cdec___pyx_scope_struct_19_lines, /*tp_clear*/ + __pyx_tp_traverse_5_cdec___pyx_scope_struct_20_lines, /*tp_traverse*/ + __pyx_tp_clear_5_cdec___pyx_scope_struct_20_lines, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_5_cdec___pyx_scope_struct_19_lines, /*tp_methods*/ + __pyx_methods_5_cdec___pyx_scope_struct_20_lines, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -26425,7 +27464,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_19_lines = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_5_cdec___pyx_scope_struct_19_lines, /*tp_new*/ + __pyx_tp_new_5_cdec___pyx_scope_struct_20_lines, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -26439,28 +27478,28 @@ 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, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ *p; +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; - p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ *)o); + p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *)o); p->__pyx_v_i = 0; p->__pyx_v_self = 0; p->__pyx_t_1 = 0; return o; } -static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_20___iter__(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ *)o; - Py_XDECREF(p->__pyx_v_i); - Py_XDECREF(((PyObject *)p->__pyx_v_self)); - Py_XDECREF(p->__pyx_t_1); +static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_21___iter__(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *)o; + Py_CLEAR(p->__pyx_v_i); + Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_t_1); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_20___iter__(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_21___iter__(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ *)o; + struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *)o; if (p->__pyx_v_i) { e = (*v)(p->__pyx_v_i, a); if (e) return e; } @@ -26473,8 +27512,8 @@ static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_20___iter__(PyObject *o, return 0; } -static int __pyx_tp_clear_5_cdec___pyx_scope_struct_20___iter__(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ *)o; +static int __pyx_tp_clear_5_cdec___pyx_scope_struct_21___iter__(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_v_i); p->__pyx_v_i = Py_None; Py_INCREF(Py_None); @@ -26488,11 +27527,11 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_20___iter__(PyObject *o) { return 0; } -static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_20___iter__[] = { +static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_21___iter__[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_20___iter__ = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_21___iter__ = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -26550,7 +27589,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_20___iter__ = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_20___iter__ = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_21___iter__ = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -26563,13 +27602,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_20___iter__ = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_20___iter__ = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_21___iter__ = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_20___iter__ = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_21___iter__ = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -26590,12 +27629,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_20___iter__ = { #endif }; -static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_20___iter__ = { +static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_21___iter__ = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_cdec.__pyx_scope_struct_20___iter__"), /*tp_name*/ - sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__), /*tp_basicsize*/ + __Pyx_NAMESTR("_cdec.__pyx_scope_struct_21___iter__"), /*tp_name*/ + sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5_cdec___pyx_scope_struct_20___iter__, /*tp_dealloc*/ + __pyx_tp_dealloc_5_cdec___pyx_scope_struct_21___iter__, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -26605,24 +27644,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_20___iter__ = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct_20___iter__, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct_20___iter__, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct_20___iter__, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_21___iter__, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_21___iter__, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_21___iter__, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct_20___iter__, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_21___iter__, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_5_cdec___pyx_scope_struct_20___iter__, /*tp_traverse*/ - __pyx_tp_clear_5_cdec___pyx_scope_struct_20___iter__, /*tp_clear*/ + __pyx_tp_traverse_5_cdec___pyx_scope_struct_21___iter__, /*tp_traverse*/ + __pyx_tp_clear_5_cdec___pyx_scope_struct_21___iter__, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_5_cdec___pyx_scope_struct_20___iter__, /*tp_methods*/ + __pyx_methods_5_cdec___pyx_scope_struct_21___iter__, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -26632,7 +27671,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_20___iter__ = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_5_cdec___pyx_scope_struct_20___iter__, /*tp_new*/ + __pyx_tp_new_5_cdec___pyx_scope_struct_21___iter__, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -26646,32 +27685,32 @@ 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, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *p; +static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_22___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *)o); + p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ *)o); p->__pyx_v_self = 0; return o; } -static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_21___iter__(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); +static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_22___iter__(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ *)o; + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_21___iter__(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_22___iter__(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *)o; + struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ *)o; if (p->__pyx_v_self) { e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; } return 0; } -static int __pyx_tp_clear_5_cdec___pyx_scope_struct_21___iter__(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *)o; +static int __pyx_tp_clear_5_cdec___pyx_scope_struct_22___iter__(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_v_self); p->__pyx_v_self = ((struct __pyx_obj_5_cdec_CandidateSet *)Py_None); Py_INCREF(Py_None); @@ -26679,11 +27718,11 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_21___iter__(PyObject *o) { return 0; } -static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_21___iter__[] = { +static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_22___iter__[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_21___iter__ = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_22___iter__ = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -26741,7 +27780,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_21___iter__ = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_21___iter__ = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_22___iter__ = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -26754,13 +27793,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_21___iter__ = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_21___iter__ = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_22___iter__ = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_21___iter__ = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_22___iter__ = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -26781,12 +27820,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_21___iter__ = { #endif }; -static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_21___iter__ = { +static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_22___iter__ = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_cdec.__pyx_scope_struct_21___iter__"), /*tp_name*/ - sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__), /*tp_basicsize*/ + __Pyx_NAMESTR("_cdec.__pyx_scope_struct_22___iter__"), /*tp_name*/ + sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5_cdec___pyx_scope_struct_21___iter__, /*tp_dealloc*/ + __pyx_tp_dealloc_5_cdec___pyx_scope_struct_22___iter__, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -26796,24 +27835,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_21___iter__ = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct_21___iter__, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct_21___iter__, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct_21___iter__, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_22___iter__, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_22___iter__, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_22___iter__, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct_21___iter__, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_22___iter__, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_5_cdec___pyx_scope_struct_21___iter__, /*tp_traverse*/ - __pyx_tp_clear_5_cdec___pyx_scope_struct_21___iter__, /*tp_clear*/ + __pyx_tp_traverse_5_cdec___pyx_scope_struct_22___iter__, /*tp_traverse*/ + __pyx_tp_clear_5_cdec___pyx_scope_struct_22___iter__, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_5_cdec___pyx_scope_struct_21___iter__, /*tp_methods*/ + __pyx_methods_5_cdec___pyx_scope_struct_22___iter__, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -26823,7 +27862,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_21___iter__ = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_5_cdec___pyx_scope_struct_21___iter__, /*tp_new*/ + __pyx_tp_new_5_cdec___pyx_scope_struct_22___iter__, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -26837,11 +27876,11 @@ 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, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *p; +static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_23__make_config(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *)o); + p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config *)o); p->__pyx_v_config = 0; p->__pyx_v_info = 0; p->__pyx_v_key = 0; @@ -26852,21 +27891,21 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_22__make_config(PyTypeOb return o; } -static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_22__make_config(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *)o; - Py_XDECREF(p->__pyx_v_config); - Py_XDECREF(p->__pyx_v_info); - Py_XDECREF(p->__pyx_v_key); - Py_XDECREF(p->__pyx_v_name); - Py_XDECREF(p->__pyx_v_value); - Py_XDECREF(p->__pyx_t_0); - Py_XDECREF(p->__pyx_t_1); +static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_23__make_config(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config *)o; + Py_CLEAR(p->__pyx_v_config); + Py_CLEAR(p->__pyx_v_info); + Py_CLEAR(p->__pyx_v_key); + Py_CLEAR(p->__pyx_v_name); + Py_CLEAR(p->__pyx_v_value); + Py_CLEAR(p->__pyx_t_0); + Py_CLEAR(p->__pyx_t_1); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_22__make_config(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_23__make_config(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *)o; + struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config *)o; if (p->__pyx_v_config) { e = (*v)(p->__pyx_v_config, a); if (e) return e; } @@ -26891,8 +27930,8 @@ static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_22__make_config(PyObject return 0; } -static int __pyx_tp_clear_5_cdec___pyx_scope_struct_22__make_config(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *)o; +static int __pyx_tp_clear_5_cdec___pyx_scope_struct_23__make_config(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_v_config); p->__pyx_v_config = Py_None; Py_INCREF(Py_None); @@ -26918,11 +27957,11 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_22__make_config(PyObject *o) return 0; } -static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_22__make_config[] = { +static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_23__make_config[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_22__make_config = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_23__make_config = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -26980,7 +28019,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_22__make_config = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_22__make_config = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_23__make_config = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -26993,13 +28032,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_22__make_config 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_22__make_config = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_23__make_config = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_22__make_config = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_23__make_config = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -27020,12 +28059,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_22__make_config = { #endif }; -static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_22__make_config = { +static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_23__make_config = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_cdec.__pyx_scope_struct_22__make_config"), /*tp_name*/ - sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config), /*tp_basicsize*/ + __Pyx_NAMESTR("_cdec.__pyx_scope_struct_23__make_config"), /*tp_name*/ + sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5_cdec___pyx_scope_struct_22__make_config, /*tp_dealloc*/ + __pyx_tp_dealloc_5_cdec___pyx_scope_struct_23__make_config, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -27035,24 +28074,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_22__make_config = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct_22__make_config, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct_22__make_config, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct_22__make_config, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_23__make_config, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_23__make_config, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_23__make_config, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct_22__make_config, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_23__make_config, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_5_cdec___pyx_scope_struct_22__make_config, /*tp_traverse*/ - __pyx_tp_clear_5_cdec___pyx_scope_struct_22__make_config, /*tp_clear*/ + __pyx_tp_traverse_5_cdec___pyx_scope_struct_23__make_config, /*tp_traverse*/ + __pyx_tp_clear_5_cdec___pyx_scope_struct_23__make_config, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_5_cdec___pyx_scope_struct_22__make_config, /*tp_methods*/ + __pyx_methods_5_cdec___pyx_scope_struct_23__make_config, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -27062,7 +28101,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_22__make_config = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_5_cdec___pyx_scope_struct_22__make_config, /*tp_new*/ + __pyx_tp_new_5_cdec___pyx_scope_struct_23__make_config, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -27076,32 +28115,32 @@ 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, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *p; +static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_24___init__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *)o); + p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *)o); p->__pyx_v_config = 0; return o; } -static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_23___cinit__(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *)o; - Py_XDECREF(p->__pyx_v_config); +static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_24___init__(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *)o; + Py_CLEAR(p->__pyx_v_config); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_23___cinit__(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_24___init__(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *)o; + struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *)o; if (p->__pyx_v_config) { e = (*v)(p->__pyx_v_config, a); if (e) return e; } return 0; } -static int __pyx_tp_clear_5_cdec___pyx_scope_struct_23___cinit__(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *)o; +static int __pyx_tp_clear_5_cdec___pyx_scope_struct_24___init__(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_v_config); p->__pyx_v_config = Py_None; Py_INCREF(Py_None); @@ -27109,11 +28148,11 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_23___cinit__(PyObject *o) { return 0; } -static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_23___cinit__[] = { +static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_24___init__[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_23___cinit__ = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_24___init__ = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -27171,7 +28210,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_23___cinit__ = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_23___cinit__ = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_24___init__ = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -27184,13 +28223,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_23___cinit__ = 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_23___cinit__ = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_24___init__ = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_23___cinit__ = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_24___init__ = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -27211,12 +28250,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_23___cinit__ = { #endif }; -static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_23___cinit__ = { +static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_24___init__ = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_cdec.__pyx_scope_struct_23___cinit__"), /*tp_name*/ - sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__), /*tp_basicsize*/ + __Pyx_NAMESTR("_cdec.__pyx_scope_struct_24___init__"), /*tp_name*/ + sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5_cdec___pyx_scope_struct_23___cinit__, /*tp_dealloc*/ + __pyx_tp_dealloc_5_cdec___pyx_scope_struct_24___init__, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -27226,24 +28265,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_23___cinit__ = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct_23___cinit__, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct_23___cinit__, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct_23___cinit__, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_24___init__, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_24___init__, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_24___init__, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct_23___cinit__, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_24___init__, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_5_cdec___pyx_scope_struct_23___cinit__, /*tp_traverse*/ - __pyx_tp_clear_5_cdec___pyx_scope_struct_23___cinit__, /*tp_clear*/ + __pyx_tp_traverse_5_cdec___pyx_scope_struct_24___init__, /*tp_traverse*/ + __pyx_tp_clear_5_cdec___pyx_scope_struct_24___init__, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_5_cdec___pyx_scope_struct_23___cinit__, /*tp_methods*/ + __pyx_methods_5_cdec___pyx_scope_struct_24___init__, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -27253,7 +28292,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_23___cinit__ = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_5_cdec___pyx_scope_struct_23___cinit__, /*tp_new*/ + __pyx_tp_new_5_cdec___pyx_scope_struct_24___init__, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -27267,28 +28306,28 @@ 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, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr *p; +static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_25_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr *)o); + p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *)o); p->__pyx_outer_scope = 0; p->__pyx_v_kv = 0; p->__pyx_t_0 = 0; return o; } -static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_24_genexpr(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr *)o; - Py_XDECREF(((PyObject *)p->__pyx_outer_scope)); - Py_XDECREF(p->__pyx_v_kv); - Py_XDECREF(p->__pyx_t_0); +static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_25_genexpr(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *)o; + Py_CLEAR(p->__pyx_outer_scope); + Py_CLEAR(p->__pyx_v_kv); + Py_CLEAR(p->__pyx_t_0); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_24_genexpr(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_25_genexpr(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr *)o; + struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *)o; if (p->__pyx_outer_scope) { e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e; } @@ -27301,11 +28340,11 @@ static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_24_genexpr(PyObject *o, v return 0; } -static int __pyx_tp_clear_5_cdec___pyx_scope_struct_24_genexpr(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr *)o; +static int __pyx_tp_clear_5_cdec___pyx_scope_struct_25_genexpr(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_outer_scope); - p->__pyx_outer_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *)Py_None); Py_INCREF(Py_None); + p->__pyx_outer_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_v_kv); p->__pyx_v_kv = Py_None; Py_INCREF(Py_None); @@ -27316,11 +28355,11 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_24_genexpr(PyObject *o) { return 0; } -static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_24_genexpr[] = { +static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_25_genexpr[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_24_genexpr = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_25_genexpr = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -27378,7 +28417,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_24_genexpr = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_24_genexpr = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_25_genexpr = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -27391,13 +28430,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_24_genexpr = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_24_genexpr = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_25_genexpr = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_24_genexpr = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_25_genexpr = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -27418,12 +28457,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_24_genexpr = { #endif }; -static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_24_genexpr = { +static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_25_genexpr = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_cdec.__pyx_scope_struct_24_genexpr"), /*tp_name*/ - sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr), /*tp_basicsize*/ + __Pyx_NAMESTR("_cdec.__pyx_scope_struct_25_genexpr"), /*tp_name*/ + sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5_cdec___pyx_scope_struct_24_genexpr, /*tp_dealloc*/ + __pyx_tp_dealloc_5_cdec___pyx_scope_struct_25_genexpr, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -27433,24 +28472,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_24_genexpr = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct_24_genexpr, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct_24_genexpr, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct_24_genexpr, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_25_genexpr, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_25_genexpr, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_25_genexpr, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct_24_genexpr, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_25_genexpr, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_5_cdec___pyx_scope_struct_24_genexpr, /*tp_traverse*/ - __pyx_tp_clear_5_cdec___pyx_scope_struct_24_genexpr, /*tp_clear*/ + __pyx_tp_traverse_5_cdec___pyx_scope_struct_25_genexpr, /*tp_traverse*/ + __pyx_tp_clear_5_cdec___pyx_scope_struct_25_genexpr, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_5_cdec___pyx_scope_struct_24_genexpr, /*tp_methods*/ + __pyx_methods_5_cdec___pyx_scope_struct_25_genexpr, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -27460,7 +28499,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_24_genexpr = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_5_cdec___pyx_scope_struct_24_genexpr, /*tp_new*/ + __pyx_tp_new_5_cdec___pyx_scope_struct_25_genexpr, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -27497,36 +28536,37 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__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}, {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0}, - {&__pyx_n_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 1}, - {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0}, + {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0}, + {&__pyx_n_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 1}, {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0}, - {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0}, + {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0}, + {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0}, {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0}, {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0}, + {&__pyx_kp_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 0}, {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0}, {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0}, {&__pyx_kp_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 0}, {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0}, {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0}, {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0}, - {&__pyx_kp_s_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 0, 1, 0}, + {&__pyx_kp_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0}, {&__pyx_kp_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 0}, - {&__pyx_kp_s_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 0, 1, 0}, + {&__pyx_kp_s_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 1, 0}, {&__pyx_kp_s_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 1, 0}, - {&__pyx_kp_s_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 0, 1, 0}, {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0}, - {&__pyx_kp_s_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 1, 0}, - {&__pyx_kp_s_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 1, 0}, + {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0}, + {&__pyx_kp_s_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 0, 1, 0}, + {&__pyx_kp_s_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 1, 0}, {&__pyx_kp_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 0}, - {&__pyx_kp_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 0}, + {&__pyx_kp_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 0}, {&__pyx_kp_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 0}, {&__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_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 0, 1, 0}, + {&__pyx_n_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 1}, {&__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_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 0, 1, 0}, + {&__pyx_kp_s_63, __pyx_k_63, sizeof(__pyx_k_63), 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}, @@ -27539,7 +28579,6 @@ 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}, @@ -27555,6 +28594,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__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__alignments, __pyx_k__alignments, sizeof(__pyx_k__alignments), 0, 0, 1, 1}, + {&__pyx_n_s__basestring, __pyx_k__basestring, sizeof(__pyx_k__basestring), 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}, {&__pyx_n_s__config, __pyx_k__config, sizeof(__pyx_k__config), 0, 0, 1, 1}, @@ -27608,6 +28649,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s__scores, __pyx_k__scores, sizeof(__pyx_k__scores), 0, 0, 1, 1}, {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1}, {&__pyx_n_s__sentence, __pyx_k__sentence, sizeof(__pyx_k__sentence), 0, 0, 1, 1}, + {&__pyx_n_s__set_silent, __pyx_k__set_silent, sizeof(__pyx_k__set_silent), 0, 0, 1, 1}, {&__pyx_n_s__span, __pyx_k__span, sizeof(__pyx_k__span), 0, 0, 1, 1}, {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1}, {&__pyx_n_s__startswith, __pyx_k__startswith, sizeof(__pyx_k__startswith), 0, 0, 1, 1}, @@ -27617,20 +28659,22 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s__utf8, __pyx_k__utf8, sizeof(__pyx_k__utf8), 0, 0, 1, 1}, {&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1}, {&__pyx_n_s__weight, __pyx_k__weight, sizeof(__pyx_k__weight), 0, 0, 1, 1}, + {&__pyx_n_s__yn, __pyx_k__yn, sizeof(__pyx_k__yn), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; 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 = 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_super = __Pyx_GetName(__pyx_b, __pyx_n_s__super); if (!__pyx_builtin_super) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_eval = __Pyx_GetName(__pyx_b, __pyx_n_s__eval); if (!__pyx_builtin_eval) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_enumerate = __Pyx_GetName(__pyx_b, __pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_IndexError = __Pyx_GetName(__pyx_b, __pyx_n_s__IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __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;} + __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 23; __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 = 34; __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 = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_super = __Pyx_GetName(__pyx_b, __pyx_n_s__super); if (!__pyx_builtin_super) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 191; __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 = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_basestring = __Pyx_GetName(__pyx_b, __pyx_n_s__basestring); if (!__pyx_builtin_basestring) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __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 = 140; __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 = 14; __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 = 26; __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 = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; @@ -27654,21 +28698,21 @@ 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":89 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":95 * 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 = 89; __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 = 95; __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":6 + /* "/home/vchahune/tools/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) # <<<<<<<<<<<<<< @@ -27682,319 +28726,308 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6)); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":212 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":226 * trule = convert_rule(trule) * elif not isinstance(trule, TRule): * raise ValueError('the grammar should contain TRule objects') # <<<<<<<<<<<<<< * _g.AddRule((<TRule> trule).rule[0]) */ - __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 212; __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 = 226; __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)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_13)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14)); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":191 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":235 * elif op == 3: # != * return not (x == y) * raise NotImplemented('comparison not implemented for HypergraphEdge') # <<<<<<<<<<<<<< * * cdef class HypergraphNode: */ - __pyx_k_tuple_18 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_18)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_18); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_17)); - PyTuple_SET_ITEM(__pyx_k_tuple_18, 0, ((PyObject *)__pyx_kp_s_17)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_18)); + __pyx_k_tuple_19 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_19); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_18)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 0, ((PyObject *)__pyx_kp_s_18)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_19)); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":228 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":272 * elif op == 3: # != * return not (x == y) * raise NotImplemented('comparison not implemented for HypergraphNode') # <<<<<<<<<<<<<< */ - __pyx_k_tuple_20 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_20); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_19)); - PyTuple_SET_ITEM(__pyx_k_tuple_20, 0, ((PyObject *)__pyx_kp_s_19)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_20)); - - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":13 - * else: - * if isinstance(inp, unicode): - * inp = inp.encode('utf8') # <<<<<<<<<<<<<< - * if not isinstance(inp, str): - * raise TypeError('Cannot create lattice from %s' % type(inp)) - */ - __pyx_k_tuple_21 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_21 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_21); - __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8)); - PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, ((PyObject *)__pyx_n_s__utf8)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_20)); + PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, ((PyObject *)__pyx_kp_s_20)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21)); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":24 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":26 * 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 = 24; __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 = 26; __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":37 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":39 * 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 = 37; __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 = 39; __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":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 = 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)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_26)); - - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":64 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":69 * for i in range(len(self)): * for label, weight, delta in self[i]: * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) # <<<<<<<<<<<<<< * yield '%d [shape=doublecircle]' % len(self) * yield '}' */ - __pyx_k_tuple_33 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_33)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_33); + __pyx_k_tuple_32 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_32)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_32); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_30)); + PyTuple_SET_ITEM(__pyx_k_tuple_32, 0, ((PyObject *)__pyx_kp_s_30)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30)); __Pyx_INCREF(((PyObject *)__pyx_kp_s_31)); - PyTuple_SET_ITEM(__pyx_k_tuple_33, 0, ((PyObject *)__pyx_kp_s_31)); + PyTuple_SET_ITEM(__pyx_k_tuple_32, 1, ((PyObject *)__pyx_kp_s_31)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_32)); - PyTuple_SET_ITEM(__pyx_k_tuple_33, 1, ((PyObject *)__pyx_kp_s_32)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_33)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_32)); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":58 - * + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":63 * def todot(self): + * """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" * def lines(): # <<<<<<<<<<<<<< * yield 'digraph lattice {' * yield 'rankdir = LR;' */ - __pyx_k_tuple_36 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_36)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_36); + __pyx_k_tuple_35 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_35)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_35); __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); - PyTuple_SET_ITEM(__pyx_k_tuple_36, 0, ((PyObject *)__pyx_n_s__i)); + PyTuple_SET_ITEM(__pyx_k_tuple_35, 0, ((PyObject *)__pyx_n_s__i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); __Pyx_INCREF(((PyObject *)__pyx_n_s__label)); - PyTuple_SET_ITEM(__pyx_k_tuple_36, 1, ((PyObject *)__pyx_n_s__label)); + PyTuple_SET_ITEM(__pyx_k_tuple_35, 1, ((PyObject *)__pyx_n_s__label)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__label)); __Pyx_INCREF(((PyObject *)__pyx_n_s__weight)); - PyTuple_SET_ITEM(__pyx_k_tuple_36, 2, ((PyObject *)__pyx_n_s__weight)); + PyTuple_SET_ITEM(__pyx_k_tuple_35, 2, ((PyObject *)__pyx_n_s__weight)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__weight)); __Pyx_INCREF(((PyObject *)__pyx_n_s__delta)); - PyTuple_SET_ITEM(__pyx_k_tuple_36, 3, ((PyObject *)__pyx_n_s__delta)); + PyTuple_SET_ITEM(__pyx_k_tuple_35, 3, ((PyObject *)__pyx_n_s__delta)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__delta)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_36)); - __pyx_k_codeobj_37 = (PyObject*)__Pyx_PyCode_New(0, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_38, __pyx_n_s__lines, 58, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_37)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_35)); + __pyx_k_codeobj_36 = (PyObject*)__Pyx_PyCode_New(0, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_37, __pyx_n_s__lines, 63, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_36)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":67 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":72 * yield '%d [shape=doublecircle]' % len(self) * yield '}' * return '\n'.join(lines()).encode('utf8') # <<<<<<<<<<<<<< + * + * def as_hypergraph(self): */ - __pyx_k_tuple_40 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_40)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_40); + __pyx_k_tuple_39 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_39)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_39); __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8)); - PyTuple_SET_ITEM(__pyx_k_tuple_40, 0, ((PyObject *)__pyx_n_s__utf8)); + PyTuple_SET_ITEM(__pyx_k_tuple_39, 0, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_40)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_39)); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":50 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":50 * def __getitem__(self, int index): * if not 0 <= index < len(self): * raise IndexError('sufficient stats vector index out of range') # <<<<<<<<<<<<<< * return self.stats[0][index] * */ - __pyx_k_tuple_42 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_42)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_42); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_41)); - PyTuple_SET_ITEM(__pyx_k_tuple_42, 0, ((PyObject *)__pyx_kp_s_41)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_41)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_42)); + __pyx_k_tuple_41 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_41)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_41); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_40)); + PyTuple_SET_ITEM(__pyx_k_tuple_41, 0, ((PyObject *)__pyx_kp_s_40)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_40)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_41)); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":84 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":84 * def __getitem__(self,int k): * if not 0 <= k < self.cs.size(): * raise IndexError('candidate set index out of range') # <<<<<<<<<<<<<< * cdef Candidate candidate = Candidate() * candidate.candidate = &self.cs[0][k] */ - __pyx_k_tuple_44 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_44)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_44); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_43)); - PyTuple_SET_ITEM(__pyx_k_tuple_44, 0, ((PyObject *)__pyx_kp_s_43)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_43)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_44)); + __pyx_k_tuple_43 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_43)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_43); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_42)); + PyTuple_SET_ITEM(__pyx_k_tuple_43, 0, ((PyObject *)__pyx_kp_s_42)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_42)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_43)); - /* "_cdec.pyx":50 - * """ + /* "_cdec.pyx":52 + * Create a decoder using a given configuration. Formalism is required.""" * if config_str is None: * formalism = config.get('formalism', None) # <<<<<<<<<<<<<< * if formalism not in ('scfg', 'fst', 'lextrans', 'pb', * 'csplit', 'tagger', 'lexalign'): */ - __pyx_k_tuple_47 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_47); + __pyx_k_tuple_46 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_46); __Pyx_INCREF(((PyObject *)__pyx_n_s__formalism)); - PyTuple_SET_ITEM(__pyx_k_tuple_47, 0, ((PyObject *)__pyx_n_s__formalism)); + PyTuple_SET_ITEM(__pyx_k_tuple_46, 0, ((PyObject *)__pyx_n_s__formalism)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__formalism)); __Pyx_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_k_tuple_47, 1, Py_None); + PyTuple_SET_ITEM(__pyx_k_tuple_46, 1, Py_None); __Pyx_GIVEREF(Py_None); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_47)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_46)); - /* "_cdec.pyx":90 + /* "_cdec.pyx":93 * 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 = 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)); + __pyx_k_tuple_50 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_50); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_49)); + PyTuple_SET_ITEM(__pyx_k_tuple_50, 0, ((PyObject *)__pyx_kp_s_49)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_49)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_50)); - /* "_cdec.pyx":88 - * + /* "_cdec.pyx":91 * def read_weights(self, weights): + * """decoder.read_weights(filename): Read decoder weights from a file.""" * 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 = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_52); + __pyx_k_tuple_51 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_51); __Pyx_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_k_tuple_52, 0, Py_None); + PyTuple_SET_ITEM(__pyx_k_tuple_51, 0, Py_None); __Pyx_GIVEREF(Py_None); __Pyx_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_k_tuple_52, 1, Py_None); + PyTuple_SET_ITEM(__pyx_k_tuple_51, 1, Py_None); __Pyx_GIVEREF(Py_None); __Pyx_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_k_tuple_52, 2, Py_None); + PyTuple_SET_ITEM(__pyx_k_tuple_51, 2, Py_None); __Pyx_GIVEREF(Py_None); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_52)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51)); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5 + /* "/home/vchahune/tools/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_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_k_tuple_55 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_55)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_55); __Pyx_INCREF(((PyObject *)__pyx_n_s__phrase)); - PyTuple_SET_ITEM(__pyx_k_tuple_56, 0, ((PyObject *)__pyx_n_s__phrase)); + PyTuple_SET_ITEM(__pyx_k_tuple_55, 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_56, 1, ((PyObject *)__pyx_n_s__genexpr)); + PyTuple_SET_ITEM(__pyx_k_tuple_55, 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_56, 2, ((PyObject *)__pyx_n_s__genexpr)); + PyTuple_SET_ITEM(__pyx_k_tuple_55, 2, ((PyObject *)__pyx_n_s__genexpr)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__genexpr)); - __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;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_55)); + __pyx_k_codeobj_56 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_55, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_57, __pyx_n_s___phrase, 5, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_56)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":190 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":194 * return [] * * 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 = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_59); + __pyx_k_tuple_58 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_58)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_58); __Pyx_INCREF(((PyObject *)__pyx_n_s__IBM_BLEU)); - PyTuple_SET_ITEM(__pyx_k_tuple_59, 0, ((PyObject *)__pyx_n_s__IBM_BLEU)); + PyTuple_SET_ITEM(__pyx_k_tuple_58, 0, ((PyObject *)__pyx_n_s__IBM_BLEU)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IBM_BLEU)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_59)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_58)); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":191 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":195 * * BLEU = Scorer('IBM_BLEU') * TER = Scorer('TER') # <<<<<<<<<<<<<< * CER = Scorer('CER') */ - __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_k_tuple_59 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_59)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_59); __Pyx_INCREF(((PyObject *)__pyx_n_s__TER)); - PyTuple_SET_ITEM(__pyx_k_tuple_60, 0, ((PyObject *)__pyx_n_s__TER)); + PyTuple_SET_ITEM(__pyx_k_tuple_59, 0, ((PyObject *)__pyx_n_s__TER)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__TER)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_59)); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":192 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":196 * BLEU = Scorer('IBM_BLEU') * TER = Scorer('TER') * CER = Scorer('CER') # <<<<<<<<<<<<<< */ - __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_k_tuple_60 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_60)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_60); __Pyx_INCREF(((PyObject *)__pyx_n_s__CER)); - PyTuple_SET_ITEM(__pyx_k_tuple_61, 0, ((PyObject *)__pyx_n_s__CER)); + PyTuple_SET_ITEM(__pyx_k_tuple_60, 0, ((PyObject *)__pyx_n_s__CER)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CER)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60)); /* "_cdec.pyx":28 * class ParseFailed(Exception): pass * + * def set_silent(yn): # <<<<<<<<<<<<<< + * """set_silent(bool): Configure the verbosity of cdec.""" + * SetSilent(yn) + */ + __pyx_k_tuple_61 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_61); + __Pyx_INCREF(((PyObject *)__pyx_n_s__yn)); + PyTuple_SET_ITEM(__pyx_k_tuple_61, 0, ((PyObject *)__pyx_n_s__yn)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__yn)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61)); + __pyx_k_codeobj_62 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_61, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_63, __pyx_n_s__set_silent, 28, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "_cdec.pyx":32 + * SetSilent(yn) + * * def _make_config(config): # <<<<<<<<<<<<<< * for key, value in config.items(): * if isinstance(value, dict): */ - __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_k_tuple_64 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_64); __Pyx_INCREF(((PyObject *)__pyx_n_s__config)); - PyTuple_SET_ITEM(__pyx_k_tuple_62, 0, ((PyObject *)__pyx_n_s__config)); + PyTuple_SET_ITEM(__pyx_k_tuple_64, 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_62, 1, ((PyObject *)__pyx_n_s__key)); + PyTuple_SET_ITEM(__pyx_k_tuple_64, 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_62, 2, ((PyObject *)__pyx_n_s__value)); + PyTuple_SET_ITEM(__pyx_k_tuple_64, 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_62, 3, ((PyObject *)__pyx_n_s__name)); + PyTuple_SET_ITEM(__pyx_k_tuple_64, 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_62, 4, ((PyObject *)__pyx_n_s__info)); + PyTuple_SET_ITEM(__pyx_k_tuple_64, 4, ((PyObject *)__pyx_n_s__info)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__info)); - __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_GIVEREF(((PyObject *)__pyx_k_tuple_64)); + __pyx_k_codeobj_65 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_64, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_63, __pyx_n_s___make_config, 32, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -28006,7 +29039,6 @@ 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; @@ -28056,16 +29088,12 @@ PyMODINIT_FUNC PyInit__cdec(void) #endif /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_cdec"), __pyx_methods, 0, 0, PYTHON_API_VERSION); + __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_cdec"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif - if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #if PY_MAJOR_VERSION < 3 - Py_INCREF(__pyx_m); - #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 (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__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 @@ -28084,47 +29112,130 @@ PyMODINIT_FUNC PyInit__cdec(void) /*--- Function export code ---*/ /*--- Type init code ---*/ 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 CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_DenseVector, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_11DenseVector___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_11DenseVector___init__.doc = __pyx_doc_5_cdec_11DenseVector___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_11DenseVector___init__; + } + } + #endif 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 = 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;} + if (PyType_Ready(&__pyx_type_5_cdec_SparseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_SparseVector, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_12SparseVector___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_12SparseVector___init__.doc = __pyx_doc_5_cdec_12SparseVector___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_12SparseVector___init__; + } + } + #endif + if (__Pyx_SetAttrString(__pyx_m, "SparseVector", (PyObject *)&__pyx_type_5_cdec_SparseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __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 = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_NT, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_2NT___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_2NT___init__.doc = __pyx_doc_5_cdec_2NT___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_2NT___init__; + } + } + #endif 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 = 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;} + if (PyType_Ready(&__pyx_type_5_cdec_NTRef) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_NTRef, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_5NTRef___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_5NTRef___init__.doc = __pyx_doc_5_cdec_5NTRef___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_5NTRef___init__; + } + } + #endif + if (__Pyx_SetAttrString(__pyx_m, "NTRef", (PyObject *)&__pyx_type_5_cdec_NTRef) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_NTRef = &__pyx_type_5_cdec_NTRef; - 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;} + if (PyType_Ready(&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_TRule, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_5TRule___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_5TRule___init__.doc = __pyx_doc_5_cdec_5TRule___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_5TRule___init__; + } + } + #endif + if (__Pyx_SetAttrString(__pyx_m, "TRule", (PyObject *)&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_TRule = &__pyx_type_5_cdec_TRule; __pyx_type_5_cdec_MRule.tp_base = __pyx_ptype_5_cdec_TRule; - if (PyType_Ready(&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "MRule", (PyObject *)&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_MRule, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_5MRule___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_5MRule___init__.doc = __pyx_doc_5_cdec_5MRule___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_5MRule___init__; + } + } + #endif + if (__Pyx_SetAttrString(__pyx_m, "MRule", (PyObject *)&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_MRule = &__pyx_type_5_cdec_MRule; - if (PyType_Ready(&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Grammar", (PyObject *)&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 193; __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 = 193; __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 = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "TextGrammar", (PyObject *)&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_TextGrammar, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_11TextGrammar___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_11TextGrammar___init__.doc = __pyx_doc_5_cdec_11TextGrammar___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_11TextGrammar___init__; + } + } + #endif + if (__Pyx_SetAttrString(__pyx_m, "TextGrammar", (PyObject *)&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_TextGrammar = &__pyx_type_5_cdec_TextGrammar; + __pyx_vtabptr_5_cdec_Hypergraph = &__pyx_vtable_5_cdec_Hypergraph; + __pyx_vtable_5_cdec_Hypergraph._rng = (MT19937 *(*)(struct __pyx_obj_5_cdec_Hypergraph *))__pyx_f_5_cdec_10Hypergraph__rng; 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_SetVtable(__pyx_type_5_cdec_Hypergraph.tp_dict, __pyx_vtabptr_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;} __pyx_ptype_5_cdec_Hypergraph = &__pyx_type_5_cdec_Hypergraph; __pyx_vtabptr_5_cdec_HypergraphEdge = &__pyx_vtable_5_cdec_HypergraphEdge; __pyx_vtable_5_cdec_HypergraphEdge.init = (PyObject *(*)(struct __pyx_obj_5_cdec_HypergraphEdge *, Hypergraph *, unsigned int))__pyx_f_5_cdec_14HypergraphEdge_init; - if (PyType_Ready(&__pyx_type_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_5_cdec_HypergraphEdge.tp_dict, __pyx_vtabptr_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "HypergraphEdge", (PyObject *)&__pyx_type_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_5_cdec_HypergraphEdge.tp_dict, __pyx_vtabptr_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "HypergraphEdge", (PyObject *)&__pyx_type_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_HypergraphEdge = &__pyx_type_5_cdec_HypergraphEdge; __pyx_vtabptr_5_cdec_HypergraphNode = &__pyx_vtable_5_cdec_HypergraphNode; __pyx_vtable_5_cdec_HypergraphNode.init = (PyObject *(*)(struct __pyx_obj_5_cdec_HypergraphNode *, Hypergraph *, unsigned int))__pyx_f_5_cdec_14HypergraphNode_init; - if (PyType_Ready(&__pyx_type_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_5_cdec_HypergraphNode.tp_dict, __pyx_vtabptr_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "HypergraphNode", (PyObject *)&__pyx_type_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_5_cdec_HypergraphNode.tp_dict, __pyx_vtabptr_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "HypergraphNode", (PyObject *)&__pyx_type_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_HypergraphNode = &__pyx_type_5_cdec_HypergraphNode; if (PyType_Ready(&__pyx_type_5_cdec_Lattice) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_Lattice, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_7Lattice_2__init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_7Lattice_2__init__.doc = __pyx_doc_5_cdec_7Lattice_2__init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_7Lattice_2__init__; + } + } + #endif if (__Pyx_SetAttrString(__pyx_m, "Lattice", (PyObject *)&__pyx_type_5_cdec_Lattice) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_Lattice = &__pyx_type_5_cdec_Lattice; if (PyType_Ready(&__pyx_type_5_cdec_Candidate) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -28136,72 +29247,89 @@ PyMODINIT_FUNC PyInit__cdec(void) if (PyType_Ready(&__pyx_type_5_cdec_CandidateSet) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_SetAttrString(__pyx_m, "CandidateSet", (PyObject *)&__pyx_type_5_cdec_CandidateSet) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_CandidateSet = &__pyx_type_5_cdec_CandidateSet; - if (PyType_Ready(&__pyx_type_5_cdec_SegmentEvaluator) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "SegmentEvaluator", (PyObject *)&__pyx_type_5_cdec_SegmentEvaluator) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_SegmentEvaluator) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "SegmentEvaluator", (PyObject *)&__pyx_type_5_cdec_SegmentEvaluator) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_SegmentEvaluator = &__pyx_type_5_cdec_SegmentEvaluator; - if (PyType_Ready(&__pyx_type_5_cdec_Scorer) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Scorer", (PyObject *)&__pyx_type_5_cdec_Scorer) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_Scorer) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Scorer", (PyObject *)&__pyx_type_5_cdec_Scorer) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_Scorer = &__pyx_type_5_cdec_Scorer; - if (PyType_Ready(&__pyx_type_5_cdec_Metric) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Metric", (PyObject *)&__pyx_type_5_cdec_Metric) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_Metric) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Metric", (PyObject *)&__pyx_type_5_cdec_Metric) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_Metric = &__pyx_type_5_cdec_Metric; - 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;} + if (PyType_Ready(&__pyx_type_5_cdec_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_Decoder, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_7Decoder___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_7Decoder___init__.doc = __pyx_doc_5_cdec_7Decoder___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_7Decoder___init__; + } + } + #endif + if (__Pyx_SetAttrString(__pyx_m, "Decoder", (PyObject *)&__pyx_type_5_cdec_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __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 = 31; __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 = 32; __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 = 67; __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 = 72; __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 = 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 = 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 = 124; __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 = 131; __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 = 164; __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 = 172; __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 = 165; __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 = 173; __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 = 187; __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 = 199; __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;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_8_kbest) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 44; __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; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_9_kbest_trees) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_9_kbest_trees) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_9_kbest_trees = &__pyx_type_5_cdec___pyx_scope_struct_9_kbest_trees; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_10_kbest_features) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_10_kbest_features) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_10_kbest_features = &__pyx_type_5_cdec___pyx_scope_struct_10_kbest_features; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_11_sample) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_11_sample) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_11_sample = &__pyx_type_5_cdec___pyx_scope_struct_11_sample; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_12___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5_cdec___pyx_scope_struct_12___get__ = &__pyx_type_5_cdec___pyx_scope_struct_12___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_13___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_12_sample_trees) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5_cdec___pyx_scope_struct_12_sample_trees = &__pyx_type_5_cdec___pyx_scope_struct_12_sample_trees; + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_13___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_13___get__ = &__pyx_type_5_cdec___pyx_scope_struct_13___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_14___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_14___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_14___get__ = &__pyx_type_5_cdec___pyx_scope_struct_14___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_15___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_15___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __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;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_16___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 247; __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 = 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; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_19_lines) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5_cdec___pyx_scope_struct_19_lines = &__pyx_type_5_cdec___pyx_scope_struct_19_lines; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_20___iter__) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5_cdec___pyx_scope_struct_20___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_20___iter__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_21___iter__) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_17___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5_cdec___pyx_scope_struct_17___get__ = &__pyx_type_5_cdec___pyx_scope_struct_17___get__; + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_18___iter__) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5_cdec___pyx_scope_struct_18___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_18___iter__; + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_19_todot) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5_cdec___pyx_scope_struct_19_todot = &__pyx_type_5_cdec___pyx_scope_struct_19_todot; + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_20_lines) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5_cdec___pyx_scope_struct_20_lines = &__pyx_type_5_cdec___pyx_scope_struct_20_lines; + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_21___iter__) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_21___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_21___iter__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_22__make_config) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5_cdec___pyx_scope_struct_22__make_config = &__pyx_type_5_cdec___pyx_scope_struct_22__make_config; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_23___cinit__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5_cdec___pyx_scope_struct_23___cinit__ = &__pyx_type_5_cdec___pyx_scope_struct_23___cinit__; - 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; + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_22___iter__) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5_cdec___pyx_scope_struct_22___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_22___iter__; + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_23__make_config) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5_cdec___pyx_scope_struct_23__make_config = &__pyx_type_5_cdec___pyx_scope_struct_23__make_config; + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_24___init__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5_cdec___pyx_scope_struct_24___init__ = &__pyx_type_5_cdec___pyx_scope_struct_24___init__; + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_25_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5_cdec___pyx_scope_struct_25_genexpr = &__pyx_type_5_cdec___pyx_scope_struct_25_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;} + __pyx_ptype_4cdec_2sa_3_sa_FloatList = __Pyx_ImportType("cdec.sa._sa", "FloatList", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_FloatList), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_FloatList)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_4cdec_2sa_3_sa_FloatList = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_FloatList*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_FloatList->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_FloatList)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_IntList = __Pyx_ImportType("cdec.sa._sa", "IntList", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_IntList), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_IntList)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_4cdec_2sa_3_sa_IntList = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_IntList->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_IntList)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_FeatureVector = __Pyx_ImportType("cdec.sa._sa", "FeatureVector", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_FeatureVector), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_FeatureVector)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 29; __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 = 29; __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 = 35; __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;} @@ -28212,7 +29340,7 @@ PyMODINIT_FUNC PyInit__cdec(void) Py_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*--- Execution code ---*/ - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":3 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":3 * cimport grammar * cimport cdec.sa._sa as _sa * import cdec.sa._sa as _sa # <<<<<<<<<<<<<< @@ -28221,16 +29349,16 @@ PyMODINIT_FUNC PyInit__cdec(void) */ __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_INCREF(((PyObject *)__pyx_n_s_54)); + PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s_54)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s_54)); + __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s_53), ((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 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":5 * import cdec.sa._sa as _sa * * def _phrase(phrase): # <<<<<<<<<<<<<< @@ -28242,37 +29370,37 @@ PyMODINIT_FUNC PyInit__cdec(void) 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 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":194 * return [] * * BLEU = Scorer('IBM_BLEU') # <<<<<<<<<<<<<< * TER = Scorer('TER') * CER = Scorer('CER') */ - __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_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_58), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 194; __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;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__BLEU, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 194; __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 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":195 * * BLEU = Scorer('IBM_BLEU') * TER = Scorer('TER') # <<<<<<<<<<<<<< * CER = Scorer('CER') */ - __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_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 = 195; __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;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__TER, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 195; __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 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":196 * BLEU = Scorer('IBM_BLEU') * TER = Scorer('TER') * CER = Scorer('CER') # <<<<<<<<<<<<<< */ - __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_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 = 196; __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;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__CER, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "_cdec.pyx":22 @@ -28319,7 +29447,7 @@ PyMODINIT_FUNC PyInit__cdec(void) * class InvalidConfig(Exception): pass * class ParseFailed(Exception): pass # <<<<<<<<<<<<<< * - * def _make_config(config): + * def set_silent(yn): */ __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)); @@ -28338,13 +29466,25 @@ PyMODINIT_FUNC PyInit__cdec(void) /* "_cdec.pyx":28 * class ParseFailed(Exception): pass * + * def set_silent(yn): # <<<<<<<<<<<<<< + * """set_silent(bool): Configure the verbosity of cdec.""" + * SetSilent(yn) + */ + __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_5_cdec_3set_silent, 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__set_silent, __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":32 + * SetSilent(yn) + * * def _make_config(config): # <<<<<<<<<<<<<< * for key, value in config.items(): * if isinstance(value, dict): */ - __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_t_3 = PyCFunction_NewEx(&__pyx_mdef_5_cdec_5_make_config, NULL, __pyx_n_s___cdec); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __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;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___make_config, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "_cdec.pyx":1 @@ -28357,11 +29497,11 @@ PyMODINIT_FUNC PyInit__cdec(void) 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 + /* "string.from_py":11 * - * @cname("__pyx_convert_string_to_py_") - * cdef object __pyx_convert_string_to_py_(string& s): # <<<<<<<<<<<<<< - * return s.data()[:s.size()] + * @cname("__pyx_convert_string_from_py_") + * cdef string __pyx_convert_string_from_py_(object o) except *: # <<<<<<<<<<<<<< + * return string(<char*>o, len(o)) * */ goto __pyx_L0; @@ -28452,33 +29592,38 @@ static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyOb static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { Py_XINCREF(type); - Py_XINCREF(value); - Py_XINCREF(tb); - if (tb == Py_None) { - Py_DECREF(tb); - tb = 0; - } - else if (tb != NULL && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - if (value == NULL) { - value = Py_None; + if (!value || value == Py_None) + value = NULL; + else Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } } #if PY_VERSION_HEX < 0x02050000 - if (!PyClass_Check(type)) + if (PyClass_Check(type)) { #else - if (!PyType_Check(type)) + if (PyType_Check(type)) { #endif - { - if (value != Py_None) { +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } - Py_DECREF(value); value = type; #if PY_VERSION_HEX < 0x02050000 if (PyInstance_Check(type)) { @@ -28511,6 +29656,7 @@ raise_error: } #else /* Python 3+ */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { @@ -28528,12 +29674,36 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } value = type; type = (PyObject*) Py_TYPE(value); - } else if (!PyExceptionClass_Check(type)) { + } else if (PyExceptionClass_Check(type)) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } + else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyEval_CallObject(type, args); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } - if (cause) { + if (cause && cause != Py_None) { PyObject *fixed_cause; if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); @@ -28550,9 +29720,6 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "BaseException"); goto bad; } - if (!value) { - value = PyObject_CallObject(type, NULL); - } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); @@ -28566,6 +29733,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } } bad: + Py_XDECREF(owned_instance); return; } #endif @@ -28590,7 +29758,7 @@ static void __Pyx_RaiseArgtupleInvalid( 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)", + "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } @@ -28610,10 +29778,9 @@ static CYTHON_INLINE int __Pyx_CheckKeywordStrings( 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 (unlikely(!PyUnicode_Check(key))) + goto invalid_keyword_type; } if ((!kw_allowed) && unlikely(key)) goto invalid_keyword; @@ -28680,7 +29847,7 @@ static void __Pyx_RaiseDoubleKeywordsError( "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AS_STRING(kw_name)); + PyString_AsString(kw_name)); #endif } @@ -28701,48 +29868,72 @@ static int __Pyx_ParseOptionalKeywords( while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; - } else { - #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; - } else { - for (name = first_kw_arg; *name; name++) { - #if PY_MAJOR_VERSION >= 3 - if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) && - PyUnicode_Compare(**name, key) == 0) break; - #else - if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) && - _PyString_Eq(**name, key)) break; - #endif - } - if (*name) { + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { values[name-argnames] = value; - } else { - for (name=argnames; name != first_kw_arg; name++) { - if (**name == key) goto arg_passed_twice; - #if PY_MAJOR_VERSION >= 3 - if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) && - PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice; - #else - if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) && - _PyString_Eq(**name, key)) goto arg_passed_twice; - #endif - } - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; } + name++; } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; } } return 0; arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, **name); + __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, @@ -28763,12 +29954,12 @@ bad: 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); + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_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 %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack", index, (index == 1) ? "" : "s"); } @@ -29136,9 +30327,8 @@ static CYTHON_INLINE WordID __Pyx_PyInt_from_py_WordID(PyObject* x) { } } -static PyObject* __Pyx_Globals() { +static PyObject* __Pyx_Globals(void) { Py_ssize_t i; - /*PyObject *d;*/ PyObject *names = NULL; PyObject *globals = PyObject_GetAttrString(__pyx_m, "__dict__"); if (!globals) { @@ -29149,25 +30339,36 @@ static PyObject* __Pyx_Globals() { names = PyObject_Dir(__pyx_m); if (!names) goto bad; - for (i = 0; i < PyList_GET_SIZE(names); i++) { + for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) { +#if CYTHON_COMPILING_IN_PYPY + PyObject* name = PySequence_GetItem(names, i); + if (!name) + goto bad; +#else PyObject* name = PyList_GET_ITEM(names, i); +#endif if (!PyDict_Contains(globals, name)) { - PyObject* value = PyObject_GetAttr(__pyx_m, PyList_GET_ITEM(names, i)); - if (!value) + PyObject* value = PyObject_GetAttr(__pyx_m, name); + if (!value) { +#if CYTHON_COMPILING_IN_PYPY + Py_DECREF(name); +#endif goto bad; + } if (PyDict_SetItem(globals, name, value) < 0) { +#if CYTHON_COMPILING_IN_PYPY + Py_DECREF(name); +#endif Py_DECREF(value); goto bad; } } +#if CYTHON_COMPILING_IN_PYPY + Py_DECREF(name); +#endif } Py_DECREF(names); return globals; - /* - d = PyDictProxy_New(globals); - Py_DECREF(globals); - return d; - */ bad: Py_XDECREF(names); Py_XDECREF(globals); @@ -29583,86 +30784,6 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyOb 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)) { - if (PyBytes_GET_SIZE(s1) != PyBytes_GET_SIZE(s2)) { - return (equals == Py_NE); - } else if (PyBytes_GET_SIZE(s1) == 1) { - if (equals == Py_EQ) - return (PyBytes_AS_STRING(s1)[0] == PyBytes_AS_STRING(s2)[0]); - else - return (PyBytes_AS_STRING(s1)[0] != PyBytes_AS_STRING(s2)[0]); - } else { - int result = memcmp(PyBytes_AS_STRING(s1), PyBytes_AS_STRING(s2), (size_t)PyBytes_GET_SIZE(s1)); - return (equals == Py_EQ) ? (result == 0) : (result != 0); - } - } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { - return (equals == Py_NE); - } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { - return (equals == Py_NE); - } else { - int result; - PyObject* py_result = PyObject_RichCompare(s1, s2, equals); - if (!py_result) - return -1; - result = __Pyx_PyObject_IsTrue(py_result); - 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)) { - #if CYTHON_PEP393_ENABLED - if ((PyUnicode_READY(s1) < 0) || (PyUnicode_READY(s2) < 0)) - return -1; - if (PyUnicode_GET_LENGTH(s1) != PyUnicode_GET_LENGTH(s2)) { - return (equals == Py_NE); - } else if (PyUnicode_GET_LENGTH(s1) == 1) { - Py_UCS4 ch1 = PyUnicode_READ_CHAR(s1, 0); - Py_UCS4 ch2 = PyUnicode_READ_CHAR(s2, 0); - return (equals == Py_EQ) ? (ch1 == ch2) : (ch1 != ch2); - #else - if (PyUnicode_GET_SIZE(s1) != PyUnicode_GET_SIZE(s2)) { - return (equals == Py_NE); - } else if (PyUnicode_GET_SIZE(s1) == 1) { - Py_UNICODE ch1 = PyUnicode_AS_UNICODE(s1)[0]; - Py_UNICODE ch2 = PyUnicode_AS_UNICODE(s2)[0]; - return (equals == Py_EQ) ? (ch1 == ch2) : (ch1 != ch2); - #endif - } else { - int result = PyUnicode_Compare(s1, s2); - if ((result == -1) && unlikely(PyErr_Occurred())) - return -1; - return (equals == Py_EQ) ? (result == 0) : (result != 0); - } - } else if ((s1 == Py_None) & PyUnicode_CheckExact(s2)) { - return (equals == Py_NE); - } else if ((s2 == Py_None) & PyUnicode_CheckExact(s1)) { - return (equals == Py_NE); - } else { - int result; - PyObject* py_result = PyObject_RichCompare(s1, s2, equals); - if (!py_result) - return -1; - result = __Pyx_PyObject_IsTrue(py_result); - Py_DECREF(py_result); - return result; - } -#endif -} - static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { const unsigned char neg_one = (unsigned char)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; @@ -30063,25 +31184,6 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* } } -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); - #if PY_MAJOR_VERSION < 3 - ctx = PyString_FromString(name); - #else - ctx = PyUnicode_FromString(name); - #endif - __Pyx_ErrRestore(old_exc, old_val, old_tb); - if (!ctx) { - PyErr_WriteUnraisable(Py_None); - } else { - PyErr_WriteUnraisable(ctx); - Py_DECREF(ctx); - } -} - static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_COMPILING_IN_CPYTHON @@ -30504,7 +31606,7 @@ static PyMemberDef __pyx_Generator_memberlist[] = { #if PY_VERSION_HEX >= 0x02060000 T_BOOL, #else - T_INT, + T_BYTE, #endif offsetof(__pyx_GeneratorObject, is_running), READONLY, @@ -30602,6 +31704,25 @@ static int __pyx_Generator_init(void) { return 0; } +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); + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +} + static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); @@ -30638,6 +31759,23 @@ bad: return -1; } +#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 + #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, @@ -30690,23 +31828,6 @@ bad: } #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__"); @@ -30745,7 +31866,7 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (** PyModule_GetName(module), funcname); goto bad; } -#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) +#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)", |