summaryrefslogtreecommitdiff
path: root/python/src/_cdec.cpp
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2012-08-03 07:46:54 -0400
committerKenneth Heafield <github@kheafield.com>2012-08-03 07:46:54 -0400
commitbe1ab0a8937f9c5668ea5e6c31b798e87672e55e (patch)
treea13aad60ab6cced213401bce6a38ac885ba171ba /python/src/_cdec.cpp
parente5d6f4ae41009c26978ecd62668501af9762b0bc (diff)
parent9fe0219562e5db25171cce8776381600ff9a5649 (diff)
Merge branch 'master' of github.com:redpony/cdec
Diffstat (limited to 'python/src/_cdec.cpp')
-rw-r--r--python/src/_cdec.cpp28140
1 files changed, 26266 insertions, 1874 deletions
diff --git a/python/src/_cdec.cpp b/python/src/_cdec.cpp
index 55470c89..dcd33448 100644
--- a/python/src/_cdec.cpp
+++ b/python/src/_cdec.cpp
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.16 on Thu Jun 14 09:24:35 2012 */
+/* Generated by Cython 0.17.beta1 on Sun Jul 29 23:00:27 2012 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -47,12 +47,6 @@
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyCFunction_Call PyObject_Call
-#else
- #define __Pyx_PyCFunction_Call PyCFunction_Call
-#endif
-
#if PY_VERSION_HEX < 0x02050000
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
@@ -60,8 +54,11 @@
#define PY_FORMAT_SIZE_T ""
#define PyInt_FromSsize_t(z) PyInt_FromLong(z)
#define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o)
- #define PyNumber_Index(o) PyNumber_Int(o)
- #define PyIndex_Check(o) PyNumber_Check(o)
+ #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
+ (PyErr_Format(PyExc_TypeError, \
+ "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
+ (PyObject*)0))
+ #define PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && !PyComplex_Check(o))
#define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#define __PYX_BUILD_PY_SSIZE_T "i"
#else
@@ -130,14 +127,20 @@
#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_GET_LENGTH)
+#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
#define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
+ #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \
+ 0 : _PyUnicode_Ready((PyObject *)(op)))
+ #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
+ #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
#else
#define CYTHON_PEP393_ENABLED 0
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
+ #define __Pyx_PyUnicode_READY(op) (0)
+ #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
+
+ #define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif
#if PY_MAJOR_VERSION >= 3
@@ -270,29 +273,40 @@
#include <math.h>
#define __PYX_HAVE___cdec
#define __PYX_HAVE_API___cdec
+#include "string.h"
#include <string>
#include <vector>
+#include <utility>
#include <iostream>
#include "utils/weights.h"
#include "utils/logval.h"
-#include "utils/prob.h"
#include "utils/wordid.h"
+#include "utils/small_vector.h"
#include "utils/sparse_vector.h"
-#include "utils/tdict.cc"
+#include "utils/tdict.h"
#include "utils/verbose.h"
#include "utils/fdict.h"
#include "utils/filelib.h"
#include "utils/sampler.h"
+#include <boost/shared_ptr.hpp>
+#include <boost/program_options.hpp>
+#include "decoder/trule.h"
+#include "decoder/grammar.h"
#include "decoder/lattice.h"
#include "decoder/hg.h"
#include "decoder/viterbi.h"
#include "decoder/hg_io.h"
#include "decoder/hg_intersect.h"
#include "decoder/hg_sampler.h"
+#include "decoder/csplit.h"
+#include "decoder/inside_outside.h"
#include "decoder/ff_register.h"
#include "decoder/decoder.h"
#include "observer.h"
#include "decoder/kbest.h"
+#include "mteval/ns.h"
+#include "py_scorer.h"
+#include "training/candidate_set.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */
@@ -347,7 +361,11 @@ static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
+#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
+#else
+#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
+#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#ifdef __GNUC__
@@ -376,146 +394,836 @@ static const char *__pyx_filename;
static const char *__pyx_f[] = {
"_cdec.pyx",
+ "vectors.pxi",
+ "grammar.pxi",
+ "hypergraph.pxi",
+ "lattice.pxi",
+ "mteval.pxi",
+ "stringsource",
+ "cdec.sa._sa.pxd",
};
/*--- Type declarations ---*/
-struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree;
-struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample;
-struct __pyx_obj_5_cdec_Weights;
+struct __pyx_obj_5_cdec_Scorer;
+struct __pyx_obj_5_cdec_NTRef;
+struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__;
+struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr;
+struct __pyx_obj_4cdec_2sa_3_sa_Phrase;
+struct __pyx_obj_5_cdec_Grammar;
+struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__;
+struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot;
+struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase;
+struct __pyx_obj_5_cdec_CandidateSet;
+struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__;
+struct __pyx_obj_5_cdec_TRule;
+struct __pyx_obj_4cdec_2sa_3_sa_Rule;
+struct __pyx_obj_5_cdec_MRule;
+struct __pyx_obj_5_cdec_SegmentEvaluator;
+struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__;
+struct __pyx_obj_5_cdec_Candidate;
+struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr;
+struct __pyx_obj_5_cdec_NT;
+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_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____iter__;
+struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__;
+struct __pyx_obj_5_cdec_DenseVector;
+struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__;
+struct __pyx_obj_5_cdec_Metric;
+struct __pyx_obj_5_cdec_SufficientStats;
+struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest;
+struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features;
+struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__;
+struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__;
+struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr;
+struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees;
struct __pyx_obj_5_cdec_Hypergraph;
struct __pyx_obj_5_cdec_Lattice;
-struct __pyx_obj_5_cdec___pyx_scope_struct____iter__;
-struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest;
+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_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 ret
+ * if isinstance(data, unicode):
+ */
+struct __pyx_opt_args_5_cdec_as_str {
+ int __pyx_n;
+ char *error_msg;
+};
-/* "_cdec.pyx":105
- * del derivations
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":117
+ * return CandidateSet(self)
*
- * def kbest_tree(self, size): # <<<<<<<<<<<<<<
- * assert (self.hg != NULL)
- * cdef kb.KBestDerivations[vector[WordID], kb.ETreeTraversal]* derivations = new kb.KBestDerivations[vector[WordID], kb.ETreeTraversal](self.hg[0], size)
+ * cdef class Scorer: # <<<<<<<<<<<<<<
+ * cdef string* name
+ * cdef mteval.EvaluationMetric* metric
*/
-struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree {
+struct __pyx_obj_5_cdec_Scorer {
PyObject_HEAD
- KBest::KBestDerivations<std::vector<WordID>,ETreeTraversal>::Derivation *__pyx_v_derivation;
- KBest::KBestDerivations<std::vector<WordID>,ETreeTraversal> *__pyx_v_derivations;
- unsigned int __pyx_v_k;
+ std::string *name;
+ EvaluationMetric *metric;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":20
+ * return '[%s]' % self.cat
+ *
+ * cdef class NTRef: # <<<<<<<<<<<<<<
+ * cdef public unsigned ref
+ * def __init__(self, unsigned ref):
+ */
+struct __pyx_obj_5_cdec_NTRef {
+ PyObject_HEAD
+ unsigned int ref;
+};
+
+
+/* "_cdec.pyx":43
+ * cdef DenseVector weights
+ *
+ * def __cinit__(self, config_str=None, **config): # <<<<<<<<<<<<<<
+ * """ Configuration can be given as a string:
+ * Decoder('formalism = scfg')
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ {
+ PyObject_HEAD
+ PyObject *__pyx_v_config;
+};
+
+
+/* "_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)
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr {
+ 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 *);
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":1
+ * cdef class Phrase: # <<<<<<<<<<<<<<
+ * cdef int *syms
+ * cdef int n, *varpos, n_vars
+ */
+struct __pyx_obj_4cdec_2sa_3_sa_Phrase {
+ PyObject_HEAD
+ struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase *__pyx_vtab;
+ int *syms;
+ int n;
+ int *varpos;
+ int n_vars;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":181
+ * super(MRule, self).__init__(lhs, rhs, e, scores, a)
+ *
+ * cdef class Grammar: # <<<<<<<<<<<<<<
+ * cdef shared_ptr[grammar.Grammar]* grammar
+ *
+ */
+struct __pyx_obj_5_cdec_Grammar {
+ PyObject_HEAD
+ boost::shared_ptr<Grammar> *grammar;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":119
+ *
+ * property nodes:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * for i in range(self.hg.nodes_.size()):
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ {
+ PyObject_HEAD
+ unsigned int __pyx_v_i;
struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self;
- PyObject *__pyx_v_sentence;
- PyObject *__pyx_v_size;
+ size_t __pyx_t_0;
+ unsigned int __pyx_t_1;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":57
+ * yield self[i]
+ *
+ * def todot(self): # <<<<<<<<<<<<<<
+ * def lines():
+ * yield 'digraph lattice {'
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot {
+ PyObject_HEAD
+ struct __pyx_obj_5_cdec_Lattice *__pyx_v_self;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5
+ * import cdec.sa._sa as _sa
+ *
+ * def _phrase(phrase): # <<<<<<<<<<<<<<
+ * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase)
+ *
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase {
+ PyObject_HEAD
+ PyObject *__pyx_v_phrase;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":65
+ * return result
+ *
+ * cdef class CandidateSet: # <<<<<<<<<<<<<<
+ * cdef shared_ptr[mteval.SegmentEvaluator]* scorer
+ * cdef mteval.EvaluationMetric* metric
+ */
+struct __pyx_obj_5_cdec_CandidateSet {
+ PyObject_HEAD
+ boost::shared_ptr<SegmentEvaluator> *scorer;
+ EvaluationMetric *metric;
+ training::CandidateSet *cs;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":167
+ *
+ * property tail_nodes:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * for i in range(self.edge.tail_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;
- long __pyx_t_1;
+ unsigned int __pyx_t_1;
};
-/* "_cdec.pyx":122
- * hypergraph.Intersect(lat.lattice[0], self.hg)
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":50
+ * return TRule(lhs, f, e, scores, a)
+ *
+ * cdef class TRule: # <<<<<<<<<<<<<<
+ * cdef shared_ptr[grammar.TRule]* rule
*
- * def sample(self, unsigned n): # <<<<<<<<<<<<<<
- * assert (self.hg != NULL)
- * cdef vector[hypergraph.Hypothesis]* hypos = new vector[hypergraph.Hypothesis]()
*/
-struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample {
+struct __pyx_obj_5_cdec_TRule {
PyObject_HEAD
- std::vector<HypergraphSampler::Hypothesis> *__pyx_v_hypos;
- unsigned int __pyx_v_k;
- unsigned int __pyx_v_n;
- struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self;
- PyObject *__pyx_v_sentence;
+ boost::shared_ptr<TRule> *rule;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":7
+ * cdef public int chunklen(self, int k)
+ *
+ * cdef class Rule: # <<<<<<<<<<<<<<
+ * cdef public int lhs
+ * cdef readonly Phrase f, e
+ */
+struct __pyx_obj_4cdec_2sa_3_sa_Rule {
+ PyObject_HEAD
+ int lhs;
+ struct __pyx_obj_4cdec_2sa_3_sa_Phrase *f;
+ struct __pyx_obj_4cdec_2sa_3_sa_Phrase *e;
+ float *cscores;
+ int n_scores;
+ PyObject *word_alignments;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":169
+ * _phrase(self.f), _phrase(self.e), scores)
+ *
+ * cdef class MRule(TRule): # <<<<<<<<<<<<<<
+ * def __init__(self, lhs, rhs, scores, a=None):
+ * cdef unsigned i = 1
+ */
+struct __pyx_obj_5_cdec_MRule {
+ struct __pyx_obj_5_cdec_TRule __pyx_base;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":98
+ * self.cs.AddKBestCandidates(hypergraph.hg[0], k, self.scorer.get())
+ *
+ * cdef class SegmentEvaluator: # <<<<<<<<<<<<<<
+ * cdef shared_ptr[mteval.SegmentEvaluator]* scorer
+ * cdef mteval.EvaluationMetric* metric
+ */
+struct __pyx_obj_5_cdec_SegmentEvaluator {
+ PyObject_HEAD
+ boost::shared_ptr<SegmentEvaluator> *scorer;
+ EvaluationMetric *metric;
+};
+
+
+/* "/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]
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ {
+ 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;
+ PyObject *(*__pyx_t_2)(PyObject *);
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":12
+ * return stats
+ *
+ * cdef class Candidate: # <<<<<<<<<<<<<<
+ * cdef mteval.const_Candidate* candidate
+ * cdef public float score
+ */
+struct __pyx_obj_5_cdec_Candidate {
+ PyObject_HEAD
+ const training::Candidate *candidate;
+ float score;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":165
+ *
+ * def __str__(self):
+ * scores = ' '.join('%s=%s' % feat for feat in self.scores) # <<<<<<<<<<<<<<
+ * return '%s ||| %s ||| %s ||| %s' % (self.lhs,
+ * _phrase(self.f), _phrase(self.e), scores)
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr {
+ PyObject_HEAD
+ struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *__pyx_outer_scope;
+ PyObject *__pyx_v_feat;
+ PyObject *__pyx_t_0;
+ Py_ssize_t __pyx_t_1;
+ PyObject *(*__pyx_t_2)(PyObject *);
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":8
+ * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase)
+ *
+ * cdef class NT: # <<<<<<<<<<<<<<
+ * cdef public bytes cat
+ * cdef public unsigned ref
+ */
+struct __pyx_obj_5_cdec_NT {
+ PyObject_HEAD
+ PyObject *cat;
+ unsigned int ref;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":147
+ * return vector
+ *
+ * cdef class HypergraphEdge: # <<<<<<<<<<<<<<
+ * cdef hypergraph.Hypergraph* hg
+ * cdef hypergraph.HypergraphEdge* edge
+ */
+struct __pyx_obj_5_cdec_HypergraphEdge {
+ PyObject_HEAD
+ struct __pyx_vtabstruct_5_cdec_HypergraphEdge *__pyx_vtab;
+ Hypergraph *hg;
+ Hypergraph::Edge *edge;
+ struct __pyx_obj_5_cdec_TRule *trule;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":67
+ * self.vector.set_value(fid, value)
+ *
+ * def __iter__(self): # <<<<<<<<<<<<<<
+ * cdef FastSparseVector[weight_t].const_iterator* it = new FastSparseVector[weight_t].const_iterator(self.vector[0], False)
+ * cdef unsigned i
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ {
+ PyObject_HEAD
+ unsigned int __pyx_v_i;
+ FastSparseVector<weight_t>::const_iterator *__pyx_v_it;
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self;
size_t __pyx_t_0;
unsigned int __pyx_t_1;
};
-/* "_cdec.pyx":15
- * pass
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":209
*
- * cdef class Weights: # <<<<<<<<<<<<<<
- * cdef vector[weight_t]* weights
+ * 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_16___get__ {
+ PyObject_HEAD
+ unsigned int __pyx_v_i;
+ 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/grammar.pxi":124
*
+ * property a:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_
*/
-struct __pyx_obj_5_cdec_Weights {
+struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ {
PyObject_HEAD
- std::vector<weight_t> *weights;
+ std::vector<AlignmentPoint> *__pyx_v_a;
+ unsigned int __pyx_v_i;
+ struct __pyx_obj_5_cdec_TRule *__pyx_v_self;
+ size_t __pyx_t_0;
+ unsigned int __pyx_t_1;
};
-/* "_cdec.pyx":38
- * yield FDConvert(fid).c_str(), self.weights[0][fid]
+/* "_cdec.pyx":39
+ * yield key, bytes(value)
*
* cdef class Decoder: # <<<<<<<<<<<<<<
* cdef decoder.Decoder* dec
- * cdef public Weights weights
+ * cdef DenseVector weights
*/
struct __pyx_obj_5_cdec_Decoder {
PyObject_HEAD
Decoder *dec;
- struct __pyx_obj_5_cdec_Weights *weights;
+ struct __pyx_obj_5_cdec_DenseVector *weights;
};
-/* "_cdec.pyx":71
- * return hg
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":193
+ * raise NotImplemented('comparison not implemented for HypergraphEdge')
*
- * cdef class Hypergraph: # <<<<<<<<<<<<<<
+ * cdef class HypergraphNode: # <<<<<<<<<<<<<<
* cdef hypergraph.Hypergraph* hg
- * cdef MT19937* rng
+ * cdef hypergraph.HypergraphNode* node
*/
-struct __pyx_obj_5_cdec_Hypergraph {
+struct __pyx_obj_5_cdec_HypergraphNode {
PyObject_HEAD
+ struct __pyx_vtabstruct_5_cdec_HypergraphNode *__pyx_vtab;
Hypergraph *hg;
- MT19937 *rng;
+ Hypergraph::Node *node;
};
-/* "_cdec.pyx":139
- * # TODO: inside-outside pruning
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":45
+ * return sparse
*
- * cdef class Lattice: # <<<<<<<<<<<<<<
- * cdef lattice.Lattice* lattice
+ * cdef class SparseVector: # <<<<<<<<<<<<<<
+ * cdef FastSparseVector[weight_t]* vector
*
*/
-struct __pyx_obj_5_cdec_Lattice {
+struct __pyx_obj_5_cdec_SparseVector {
PyObject_HEAD
- Lattice *lattice;
+ FastSparseVector<weight_t> *vector;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":52
+ * return hypergraph.AsPLF(self.lattice[0], True).c_str()
+ *
+ * def __iter__(self): # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * for i in range(len(self)):
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_17___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":33
- * self.weights[0][fid] = value
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":31
+ * self.vector[0][fid] = value
*
* def __iter__(self): # <<<<<<<<<<<<<<
* cdef unsigned fid
- * for fid in range(1, self.weights.size()):
+ * for fid in range(1, self.vector.size()):
*/
struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ {
PyObject_HEAD
unsigned int __pyx_v_fid;
- struct __pyx_obj_5_cdec_Weights *__pyx_v_self;
+ struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self;
size_t __pyx_t_0;
unsigned int __pyx_t_1;
};
-/* "_cdec.pyx":92
- * return tree.decode('utf8')
+/* "/Users/vchahun/Sandbox/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_21___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;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":3
+ * from cython.operator cimport preincrement as pinc
+ *
+ * cdef class DenseVector: # <<<<<<<<<<<<<<
+ * cdef vector[weight_t]* vector
+ * cdef bint owned # if True, do not manage memory
+ */
+struct __pyx_obj_5_cdec_DenseVector {
+ PyObject_HEAD
+ std::vector<weight_t> *vector;
+ int owned;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":187
+ * del self.grammar
+ *
+ * def __iter__(self): # <<<<<<<<<<<<<<
+ * cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot()
+ * cdef grammar.const_RuleBin* rbin = root.GetRules()
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ {
+ PyObject_HEAD
+ unsigned int __pyx_v_i;
+ const RuleBin *__pyx_v_rbin;
+ const GrammarIter *__pyx_v_root;
+ struct __pyx_obj_5_cdec_Grammar *__pyx_v_self;
+ struct __pyx_obj_5_cdec_TRule *__pyx_v_trule;
+ int __pyx_t_0;
+ unsigned int __pyx_t_1;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":173
+ * out.fields[i] = ss[i]
+ *
+ * cdef class Metric: # <<<<<<<<<<<<<<
+ * cdef Scorer scorer
+ * def __cinit__(self):
+ */
+struct __pyx_obj_5_cdec_Metric {
+ PyObject_HEAD
+ struct __pyx_obj_5_cdec_Scorer *scorer;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":26
+ * return fmap
+ *
+ * cdef class SufficientStats: # <<<<<<<<<<<<<<
+ * cdef mteval.SufficientStats* stats
+ * cdef mteval.EvaluationMetric* metric
+ */
+struct __pyx_obj_5_cdec_SufficientStats {
+ PyObject_HEAD
+ SufficientStats *stats;
+ EvaluationMetric *metric;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":31
+ * return unicode(hypergraph.JoshuaVisualizationString(self.hg[0]).c_str(), 'utf8')
*
* def kbest(self, size): # <<<<<<<<<<<<<<
- * assert (self.hg != NULL)
- * cdef kb.KBestDerivations[vector[WordID], kb.ESentenceTraversal]* derivations = new kb.KBestDerivations[vector[WordID], kb.ESentenceTraversal](self.hg[0], size)
+ * 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_1_kbest {
+struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest {
PyObject_HEAD
KBest::KBestDerivations<std::vector<WordID>,ESentenceTraversal>::Derivation *__pyx_v_derivation;
KBest::KBestDerivations<std::vector<WordID>,ESentenceTraversal> *__pyx_v_derivations;
unsigned int __pyx_v_k;
struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self;
PyObject *__pyx_v_size;
- PyObject *__pyx_v_tree;
unsigned int __pyx_t_0;
long __pyx_t_1;
};
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":61
+ * del e_derivations
+ *
+ * def kbest_features(self, size): # <<<<<<<<<<<<<<
+ * 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
+ KBest::KBestDerivations<FastSparseVector<weight_t>,FeatureVectorTraversal>::Derivation *__pyx_v_derivation;
+ KBest::KBestDerivations<FastSparseVector<weight_t>,FeatureVectorTraversal> *__pyx_v_derivations;
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_fmap;
+ unsigned int __pyx_v_k;
+ struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self;
+ PyObject *__pyx_v_size;
+ unsigned int __pyx_t_0;
+ long __pyx_t_1;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":203
+ *
+ * property in_edges:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * for i in range(self.node.in_edges_.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;
+ unsigned int __pyx_t_1;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":164
+ * self.rule.get().lhs_ = -TDConvert(<char *>lhs.cat)
+ *
+ * def __str__(self): # <<<<<<<<<<<<<<
+ * scores = ' '.join('%s=%s' % feat for feat in self.scores)
+ * return '%s ||| %s ||| %s ||| %s' % (self.lhs,
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ {
+ PyObject_HEAD
+ struct __pyx_obj_5_cdec_TRule *__pyx_v_self;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":6
+ *
+ * def _phrase(phrase):
+ * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) # <<<<<<<<<<<<<<
+ *
+ * cdef class NT:
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr {
+ PyObject_HEAD
+ struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *__pyx_outer_scope;
+ PyObject *__pyx_v_w;
+ PyObject *__pyx_t_0;
+ Py_ssize_t __pyx_t_1;
+ PyObject *(*__pyx_t_2)(PyObject *);
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":43
+ * del derivations
+ *
+ * def kbest_trees(self, size): # <<<<<<<<<<<<<<
+ * 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
+ KBest::KBestDerivations<std::vector<WordID>,ETreeTraversal>::Derivation *__pyx_v_e_derivation;
+ KBest::KBestDerivations<std::vector<WordID>,ETreeTraversal> *__pyx_v_e_derivations;
+ PyObject *__pyx_v_e_tree;
+ KBest::KBestDerivations<std::vector<WordID>,FTreeTraversal>::Derivation *__pyx_v_f_derivation;
+ KBest::KBestDerivations<std::vector<WordID>,FTreeTraversal> *__pyx_v_f_derivations;
+ PyObject *__pyx_v_f_tree;
+ unsigned int __pyx_v_k;
+ struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self;
+ PyObject *__pyx_v_size;
+ unsigned int __pyx_t_0;
+ long __pyx_t_1;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":4
+ * cimport kbest
+ *
+ * cdef class Hypergraph: # <<<<<<<<<<<<<<
+ * cdef hypergraph.Hypergraph* hg
+ * cdef MT19937* rng
+ */
+struct __pyx_obj_5_cdec_Hypergraph {
+ PyObject_HEAD
+ Hypergraph *hg;
+ MT19937 *rng;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":3
+ * cimport lattice
+ *
+ * cdef class Lattice: # <<<<<<<<<<<<<<
+ * cdef lattice.Lattice* lattice
+ *
+ */
+struct __pyx_obj_5_cdec_Lattice {
+ PyObject_HEAD
+ Lattice *lattice;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":76
+ * del derivations
+ *
+ * def sample(self, unsigned n): # <<<<<<<<<<<<<<
+ * 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
+ std::vector<HypergraphSampler::Hypothesis> *__pyx_v_hypos;
+ unsigned int __pyx_v_k;
+ unsigned int __pyx_v_n;
+ 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/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
+ *
+ * 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 {
+ PyObject_HEAD
+ PyObject *__pyx_v_config;
+ PyObject *__pyx_v_info;
+ PyObject *__pyx_v_key;
+ PyObject *__pyx_v_name;
+ PyObject *__pyx_v_value;
+ PyObject *__pyx_t_0;
+ PyObject *__pyx_t_1;
+ Py_ssize_t __pyx_t_2;
+ PyObject *(*__pyx_t_3)(PyObject *);
+ Py_ssize_t __pyx_t_4;
+ PyObject *(*__pyx_t_5)(PyObject *);
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":204
+ * self.grammar.get().SetGrammarName(string(<char *>name))
+ *
+ * cdef class TextGrammar(Grammar): # <<<<<<<<<<<<<<
+ * def __cinit__(self, rules):
+ * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar())
+ */
+struct __pyx_obj_5_cdec_TextGrammar {
+ struct __pyx_obj_5_cdec_Grammar __pyx_base;
+};
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":58
+ *
+ * def todot(self):
+ * def lines(): # <<<<<<<<<<<<<<
+ * yield 'digraph lattice {'
+ * yield 'rankdir = LR;'
+ */
+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 *);
+};
+
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":1
+ * cdef class Phrase: # <<<<<<<<<<<<<<
+ * cdef int *syms
+ * cdef int n, *varpos, n_vars
+ */
+
+struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase {
+ int (*chunkpos)(struct __pyx_obj_4cdec_2sa_3_sa_Phrase *, int);
+ int (*chunklen)(struct __pyx_obj_4cdec_2sa_3_sa_Phrase *, int);
+};
+static struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase *__pyx_vtabptr_4cdec_2sa_3_sa_Phrase;
+
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":193
+ * raise NotImplemented('comparison not implemented for HypergraphEdge')
+ *
+ * cdef class HypergraphNode: # <<<<<<<<<<<<<<
+ * cdef hypergraph.Hypergraph* hg
+ * cdef hypergraph.HypergraphNode* node
+ */
+
+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
@@ -572,48 +1280,290 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest {
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/
+static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
- const char* function_name); /*proto*/
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
+static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); /*proto*/
+
static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
const char *name, int exact); /*proto*/
-static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
-static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
+static CYTHON_INLINE PyObject* __Pyx_tp_new(PyObject* type_obj) {
+ return (PyObject*) (((PyTypeObject*)(type_obj))->tp_new(
+ (PyTypeObject*)(type_obj), __pyx_empty_tuple, NULL));
+}
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
+static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
-static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
+static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);
+
+static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/
+
+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;
+ Py_INCREF(Py_None);
+ return Py_None; /* this is just to have an accurate signature */
+ } else {
+ PyObject *r, *m;
+ m = __Pyx_GetAttrString(L, "append");
+ if (!m) return NULL;
+ r = PyObject_CallFunctionObjArgs(m, x, NULL);
+ Py_DECREF(m);
+ return r;
+ }
+}
+
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
+ PyObject *r;
+ if (!j) return NULL;
+ r = PyObject_GetItem(o, j);
+ Py_DECREF(j);
+ return r;
+}
+#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
+ __Pyx_GetItemInt_List_Fast(o, i) : \
+ __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
+#if CYTHON_COMPILING_IN_CPYTHON
+ if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+ PyObject *r = PyList_GET_ITEM(o, i);
+ Py_INCREF(r);
+ return r;
+ }
+ else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
+ PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
+ Py_INCREF(r);
+ return r;
+ }
+ return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+#else
+ return PySequence_GetItem(o, i);
+#endif
+}
+#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
+ __Pyx_GetItemInt_Tuple_Fast(o, i) : \
+ __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
+#if CYTHON_COMPILING_IN_CPYTHON
+ if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
+ PyObject *r = PyTuple_GET_ITEM(o, i);
+ Py_INCREF(r);
+ return r;
+ }
+ else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
+ PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
+ Py_INCREF(r);
+ return r;
+ }
+ return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+#else
+ return PySequence_GetItem(o, i);
+#endif
+}
+#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
+ __Pyx_GetItemInt_Fast(o, i) : \
+ __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
+#if CYTHON_COMPILING_IN_CPYTHON
+ if (PyList_CheckExact(o)) {
+ Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
+ if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
+ PyObject *r = PyList_GET_ITEM(o, n);
+ Py_INCREF(r);
+ return r;
+ }
+ }
+ else if (PyTuple_CheckExact(o)) {
+ Py_ssize_t n = (likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
+ if (likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
+ PyObject *r = PyTuple_GET_ITEM(o, n);
+ Py_INCREF(r);
+ return r;
+ }
+ } else { /* inlined PySequence_GetItem() */
+ PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
+ if (likely(m && m->sq_item)) {
+ if (unlikely(i < 0) && likely(m->sq_length)) {
+ Py_ssize_t l = m->sq_length(o);
+ if (unlikely(l < 0)) return NULL;
+ i += l;
+ }
+ return m->sq_item(o, i);
+ }
+ }
+#else
+ if (PySequence_Check(o)) {
+ return PySequence_GetItem(o, i);
+ }
+#endif
+ return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+}
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
+static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
+
+static CYTHON_INLINE 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);
+}
+
+#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
+static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *); /*proto*/
+
static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */
+#if CYTHON_COMPILING_IN_PYPY
+#define __Pyx_PyObject_AsDouble(obj) \
+(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) : \
+ likely(PyInt_CheckExact(obj)) ? \
+ PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
+#else
#define __Pyx_PyObject_AsDouble(obj) \
((likely(PyFloat_CheckExact(obj))) ? \
PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
+#endif
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
-static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
-
static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/
+
static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/
static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
PyObject *modname); /*proto*/
+#ifndef __Pyx_CppExn2PyErr
+#include <new>
+#include <typeinfo>
+#include <stdexcept>
+#include <ios>
+static void __Pyx_CppExn2PyErr() {
+ try {
+ if (PyErr_Occurred())
+ ; // let the latest Python exn pass through and ignore the current one
+ else
+ throw;
+ } catch (const std::bad_alloc& exn) {
+ PyErr_SetString(PyExc_MemoryError, exn.what());
+ } catch (const std::bad_cast& exn) {
+ PyErr_SetString(PyExc_TypeError, exn.what());
+ } catch (const std::domain_error& exn) {
+ PyErr_SetString(PyExc_ValueError, exn.what());
+ } catch (const std::invalid_argument& exn) {
+ PyErr_SetString(PyExc_ValueError, exn.what());
+ } catch (const std::ios_base::failure& exn) {
+ PyErr_SetString(PyExc_IOError, exn.what());
+ } catch (const std::out_of_range& exn) {
+ PyErr_SetString(PyExc_IndexError, exn.what());
+ } catch (const std::overflow_error& exn) {
+ PyErr_SetString(PyExc_OverflowError, exn.what());
+ } catch (const std::range_error& exn) {
+ PyErr_SetString(PyExc_ArithmeticError, exn.what());
+ } catch (const std::underflow_error& exn) {
+ PyErr_SetString(PyExc_ArithmeticError, exn.what());
+ } catch (const std::exception& exn) {
+ PyErr_SetString(PyExc_RuntimeError, exn.what());
+ }
+ catch (...)
+ {
+ PyErr_SetString(PyExc_RuntimeError, "Unknown exception");
+ }
+}
+#endif
+
+static CYTHON_INLINE WordID __Pyx_PyInt_from_py_WordID(PyObject *);
+
static PyObject* __Pyx_Globals(void); /*proto*/
+#define __Pyx_CyFunction_USED 1
+#include <structmember.h>
+#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
+#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
+#define __Pyx_CYFUNCTION_CCLASS 0x04
+#define __Pyx_CyFunction_GetClosure(f) \
+ (((__pyx_CyFunctionObject *) (f))->func_closure)
+#define __Pyx_CyFunction_GetClassObj(f) \
+ (((__pyx_CyFunctionObject *) (f))->func_classobj)
+#define __Pyx_CyFunction_Defaults(type, f) \
+ ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
+#define __Pyx_CyFunction_SetDefaultsGetter(f, g) \
+ ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
+typedef struct {
+ PyCFunctionObject func;
+ int flags;
+ PyObject *func_dict;
+ PyObject *func_weakreflist;
+ PyObject *func_name;
+ PyObject *func_doc;
+ PyObject *func_code;
+ PyObject *func_closure;
+ PyObject *func_classobj; /* No-args super() class cell */
+ void *defaults;
+ int defaults_pyobjects;
+ PyObject *defaults_tuple; /* Const defaults tuple */
+ PyObject *(*defaults_getter)(PyObject *);
+} __pyx_CyFunctionObject;
+static PyTypeObject *__pyx_CyFunctionType = 0;
+#define __Pyx_CyFunction_NewEx(ml, flags, self, module, code) \
+ __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, self, module, code)
+static PyObject *__Pyx_CyFunction_New(PyTypeObject *,
+ PyMethodDef *ml, int flags,
+ PyObject *self, PyObject *module,
+ PyObject* code);
+static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
+ size_t size,
+ int pyobjects);
+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 *);
@@ -646,10 +1596,14 @@ 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
#include <structmember.h>
+#include <frameobject.h>
typedef PyObject *(*__pyx_generator_body_t)(PyObject *, PyObject *);
typedef struct {
PyObject_HEAD
@@ -662,13 +1616,38 @@ typedef struct {
PyObject *exc_traceback;
PyObject *gi_weakreflist;
PyObject *classobj;
+ PyObject *yieldfrom;
} __pyx_GeneratorObject;
static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
PyObject *closure);
static int __pyx_Generator_init(void);
+static int __Pyx_Generator_clear(PyObject* self);
+#if 1 || PY_VERSION_HEX < 0x030300B0
+static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue);
+#else
+#define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue)
+#endif
static int __Pyx_check_binary_version(void);
+static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
+
+#if !defined(__Pyx_PyIdentifier_FromString)
+#if PY_MAJOR_VERSION < 3
+ #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
+#else
+ #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
+#endif
+#endif
+
+static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/
+
+static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
+
+static void* __Pyx_GetVtable(PyObject *dict); /*proto*/
+
+static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/
+
typedef struct {
int code_line;
PyCodeObject* code_object;
@@ -689,223 +1668,842 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line,
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+/* Module declarations from 'libc.string' */
+
/* Module declarations from 'libcpp.string' */
/* Module declarations from 'libcpp.vector' */
+/* Module declarations from 'libcpp.utility' */
+
+/* Module declarations from 'libcpp.pair' */
+
/* Module declarations from 'utils' */
+/* Module declarations from 'grammar' */
+
/* Module declarations from 'lattice' */
/* Module declarations from 'hypergraph' */
/* Module declarations from 'decoder' */
+/* Module declarations from 'cdec.sa._sa' */
+static PyTypeObject *__pyx_ptype_4cdec_2sa_3_sa_Phrase = 0;
+static PyTypeObject *__pyx_ptype_4cdec_2sa_3_sa_Rule = 0;
+static char *(*__pyx_f_4cdec_2sa_3_sa_sym_tostring)(int); /*proto*/
+static char *(*__pyx_f_4cdec_2sa_3_sa_sym_tocat)(int); /*proto*/
+static int (*__pyx_f_4cdec_2sa_3_sa_sym_isvar)(int); /*proto*/
+static int (*__pyx_f_4cdec_2sa_3_sa_sym_getindex)(int); /*proto*/
+
/* Module declarations from 'kbest' */
+/* Module declarations from 'mteval' */
+
/* Module declarations from '_cdec' */
-static PyTypeObject *__pyx_ptype_5_cdec_Weights = 0;
-static PyTypeObject *__pyx_ptype_5_cdec_Decoder = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_DenseVector = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_SparseVector = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_NT = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_NTRef = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_TRule = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_MRule = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_Grammar = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_TextGrammar = 0;
static PyTypeObject *__pyx_ptype_5_cdec_Hypergraph = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_HypergraphEdge = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_HypergraphNode = 0;
static PyTypeObject *__pyx_ptype_5_cdec_Lattice = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_Candidate = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_SufficientStats = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_CandidateSet = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_SegmentEvaluator = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_Scorer = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_Metric = 0;
+static PyTypeObject *__pyx_ptype_5_cdec_Decoder = 0;
static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct____iter__ = 0;
-static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_1_kbest = 0;
-static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_2_kbest_tree = 0;
-static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_3_sample = 0;
+static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_1___iter__ = 0;
+static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_2__phrase = 0;
+static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_3_genexpr = 0;
+static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_4___get__ = 0;
+static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_5___str__ = 0;
+static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_6_genexpr = 0;
+static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_7___iter__ = 0;
+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_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_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 struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_obj_4cdec_2sa_3_sa_Rule *); /*proto*/
+static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject *, PyObject *); /*proto*/
+static float __pyx_f_5_cdec__compute_score(void *, SufficientStats *); /*proto*/
+static void __pyx_f_5_cdec__compute_sufficient_stats(void *, std::string *, std::vector<std::string> *, SufficientStats *); /*proto*/
+static PyObject *__pyx_convert_string_to_py_(const std::string &); /*proto*/
#define __Pyx_MODULE_NAME "_cdec"
int __pyx_module_is_main__cdec = 0;
/* Implementation of '_cdec' */
static PyObject *__pyx_builtin_Exception;
+static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_range;
-static PyObject *__pyx_builtin_open;
+static PyObject *__pyx_builtin_NotImplemented;
+static PyObject *__pyx_builtin_super;
+static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_eval;
-static int __pyx_pf_5_cdec_7Weights___cinit__(struct __pyx_obj_5_cdec_Weights *__pyx_v_self, struct __pyx_obj_5_cdec_Decoder *__pyx_v_decoder); /* proto */
-static PyObject *__pyx_pf_5_cdec_7Weights_2__getitem__(struct __pyx_obj_5_cdec_Weights *__pyx_v_self, char *__pyx_v_fname); /* proto */
-static int __pyx_pf_5_cdec_7Weights_4__setitem__(struct __pyx_obj_5_cdec_Weights *__pyx_v_self, char *__pyx_v_fname, float __pyx_v_value); /* proto */
-static PyObject *__pyx_pf_5_cdec_7Weights_6__iter__(struct __pyx_obj_5_cdec_Weights *__pyx_v_self); /* proto */
-static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, char *__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_4read_weights(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_cfg); /* proto */
-static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_sentence, PyObject *__pyx_v_grammar); /* 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_value); /* proto */
-static int __pyx_pf_5_cdec_7Decoder_7weights_4__del__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self); /* proto */
+static PyObject *__pyx_builtin_enumerate;
+static PyObject *__pyx_builtin_IndexError;
+static PyObject *__pyx_builtin_open;
+static int __pyx_pf_5_cdec_11DenseVector___init__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self); /* proto */
+static void __pyx_pf_5_cdec_11DenseVector_2__dealloc__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self); /* proto */
+static Py_ssize_t __pyx_pf_5_cdec_11DenseVector_4__len__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_11DenseVector_6__getitem__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, char *__pyx_v_fname); /* proto */
+static int __pyx_pf_5_cdec_11DenseVector_8__setitem__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, char *__pyx_v_fname, float __pyx_v_value); /* proto */
+static PyObject *__pyx_pf_5_cdec_11DenseVector_10__iter__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_11DenseVector_13dot(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other); /* proto */
+static PyObject *__pyx_pf_5_cdec_11DenseVector_15tosparse(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_12SparseVector___init__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
+static void __pyx_pf_5_cdec_12SparseVector_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_4copy(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_6__getitem__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname); /* proto */
+static int __pyx_pf_5_cdec_12SparseVector_8__setitem__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname, float __pyx_v_value); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_10__iter__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y, int __pyx_v_op); /* proto */
+static Py_ssize_t __pyx_pf_5_cdec_12SparseVector_17__len__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_12SparseVector_19__contains__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_21__neg__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_23__iadd__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_25__isub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_27__imul__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar); /* proto */
+#if PY_MAJOR_VERSION < 3
+static PyObject *__pyx_pf_5_cdec_12SparseVector_29__idiv__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar); /* proto */
+#endif
+static PyObject *__pyx_pf_5_cdec_12SparseVector_31__add__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_33__sub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_35__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
+#if PY_MAJOR_VERSION < 3
+static PyObject *__pyx_pf_5_cdec_12SparseVector_37__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
+#endif
+static PyObject *__pyx_pf_5_cdec_7_phrase_genexpr(PyObject *__pyx_self); /* proto */
+static PyObject *__pyx_pf_5_cdec__phrase(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_phrase); /* proto */
+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 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 */
+static int __pyx_pf_5_cdec_2NT_3cat_4__del__(struct __pyx_obj_5_cdec_NT *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_2NT_3ref___get__(struct __pyx_obj_5_cdec_NT *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_2NT_3ref_2__set__(struct __pyx_obj_5_cdec_NT *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
+static int __pyx_pf_5_cdec_5NTRef___init__(struct __pyx_obj_5_cdec_NTRef *__pyx_v_self, unsigned int __pyx_v_ref); /* proto */
+static PyObject *__pyx_pf_5_cdec_5NTRef_2__str__(struct __pyx_obj_5_cdec_NTRef *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_5NTRef_3ref___get__(struct __pyx_obj_5_cdec_NTRef *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_5NTRef_3ref_2__set__(struct __pyx_obj_5_cdec_NTRef *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
+static int __pyx_pf_5_cdec_5TRule___init__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_f, PyObject *__pyx_v_e, PyObject *__pyx_v_scores, PyObject *__pyx_v_a); /* proto */
+static void __pyx_pf_5_cdec_5TRule_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_5TRule_5arity___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_f); /* proto */
+static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_e); /* proto */
+static PyObject *__pyx_pf_5_cdec_5TRule_1a___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_a); /* proto */
+static PyObject *__pyx_pf_5_cdec_5TRule_6scores___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_scores); /* proto */
+static PyObject *__pyx_pf_5_cdec_5TRule_3lhs___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_lhs); /* proto */
+static PyObject *__pyx_pf_5_cdec_5TRule_7__str___genexpr(PyObject *__pyx_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_rhs, PyObject *__pyx_v_scores, PyObject *__pyx_v_a); /* proto */
+static void __pyx_pf_5_cdec_7Grammar___dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Grammar *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_7Grammar_2__iter__(struct __pyx_obj_5_cdec_Grammar *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_7Grammar_4name___get__(struct __pyx_obj_5_cdec_Grammar *__pyx_v_self); /* proto */
+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 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_tree(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5_cdec_10Hypergraph_6kbest(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size); /* proto */
-static PyObject *__pyx_pf_5_cdec_10Hypergraph_9kbest_tree(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size); /* proto */
-static PyObject *__pyx_pf_5_cdec_10Hypergraph_12intersect(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_14sample(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, unsigned int __pyx_v_n); /* proto */
-static int __pyx_pf_5_cdec_7Lattice___init__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, PyObject *__pyx_v_plf_tuple); /* proto */
-static PyObject *__pyx_pf_5_cdec_7Lattice_2__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5_cdec_7Lattice_4__iter__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
-static void __pyx_pf_5_cdec_7Lattice_6__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_10Hypergraph_6viterbi_features(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_10Hypergraph_8viterbi_joshua(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_10Hypergraph_10kbest(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size); /* proto */
+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_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 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 */
+static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4span___get__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_14feature_values___get__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4prob___get__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self); /* proto */
+static PyObject *__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); /* proto */
+static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_5trule___get__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_14HypergraphEdge_5trule_2__set__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
+static int __pyx_pf_5_cdec_14HypergraphEdge_5trule_4__del__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_14HypergraphNode_8in_edges___get__(struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_14HypergraphNode_9out_edges___get__(struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_self); /* proto */
+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 PyObject *__pyx_pf_5_cdec_7Lattice_5todot_lines(PyObject *__pyx_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_7Lattice_15todot(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_9Candidate_5words___get__(struct __pyx_obj_5_cdec_Candidate *__pyx_v_self); /* proto */
+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 */
+static int __pyx_pf_5_cdec_9Candidate_5score_2__set__(struct __pyx_obj_5_cdec_Candidate *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
+static void __pyx_pf_5_cdec_15SufficientStats___dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_15SufficientStats_5score___get__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_15SufficientStats_6detail___get__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self); /* proto */
+static Py_ssize_t __pyx_pf_5_cdec_15SufficientStats_2__len__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_15SufficientStats_4__iter__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_15SufficientStats_7__getitem__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self, int __pyx_v_index); /* proto */
+static PyObject *__pyx_pf_5_cdec_15SufficientStats_9__iadd__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self, struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_other); /* proto */
+static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
+static int __pyx_pf_5_cdec_12CandidateSet___cinit__(struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self, struct __pyx_obj_5_cdec_SegmentEvaluator *__pyx_v_evaluator); /* proto */
+static void __pyx_pf_5_cdec_12CandidateSet_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self); /* proto */
+static Py_ssize_t __pyx_pf_5_cdec_12CandidateSet_4__len__(struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self, int __pyx_v_k); /* proto */
+static PyObject *__pyx_pf_5_cdec_12CandidateSet_8__iter__(struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self); /* proto */
+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); /* proto */
+static void __pyx_pf_5_cdec_16SegmentEvaluator___dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_SegmentEvaluator *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_2evaluate(struct __pyx_obj_5_cdec_SegmentEvaluator *__pyx_v_self, PyObject *__pyx_v_sentence); /* proto */
+static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_4candidate_set(struct __pyx_obj_5_cdec_SegmentEvaluator *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_6Scorer___cinit__(struct __pyx_obj_5_cdec_Scorer *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
+static void __pyx_pf_5_cdec_6Scorer_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Scorer *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Scorer *__pyx_v_self, PyObject *__pyx_v_refs); /* proto */
+static PyObject *__pyx_pf_5_cdec_6Scorer_6__str__(struct __pyx_obj_5_cdec_Scorer *__pyx_v_self); /* proto */
+static int __pyx_pf_5_cdec_6Metric___cinit__(struct __pyx_obj_5_cdec_Metric *__pyx_v_self); /* proto */
+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 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 */
+static PyObject *__pyx_pf_5_cdec_7Decoder_9formalism___get__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_weights); /* proto */
+static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_sentence, PyObject *__pyx_v_grammar); /* proto */
+static char __pyx_k_1[] = "Cannot convert type %s to str";
+static char __pyx_k_3[] = "cannot take the dot product of %s and SparseVector";
+static char __pyx_k_4[] = "comparison not implemented for SparseVector";
+static char __pyx_k_7[] = " ";
+static char __pyx_k_8[] = "[%s,%d]";
+static char __pyx_k_9[] = "[%s]";
+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_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__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__CER[] = "CER";
+static char __pyx_k__TER[] = "TER";
+static char __pyx_k___sa[] = "_sa";
+static char __pyx_k__cat[] = "cat";
+static char __pyx_k__dot[] = "dot";
+static char __pyx_k__fst[] = "fst";
+static char __pyx_k__get[] = "get";
+static char __pyx_k__hyp[] = "hyp";
+static char __pyx_k__inp[] = "inp";
+static char __pyx_k__key[] = "key";
+static char __pyx_k__lhs[] = "lhs";
+static char __pyx_k__plf[] = "plf";
+static char __pyx_k__ref[] = "ref";
+static char __pyx_k__rhs[] = "rhs";
+static char __pyx_k__BLEU[] = "BLEU";
static char __pyx_k__eval[] = "eval";
+static char __pyx_k__info[] = "info";
+static char __pyx_k__join[] = "join";
+static char __pyx_k__name[] = "name";
static char __pyx_k__open[] = "open";
+static char __pyx_k__refs[] = "refs";
+static char __pyx_k__scfg[] = "scfg";
static char __pyx_k__self[] = "self";
+static char __pyx_k__span[] = "span";
static char __pyx_k__utf8[] = "utf8";
static char __pyx_k___cdec[] = "_cdec";
+static char __pyx_k__delta[] = "delta";
+static char __pyx_k__items[] = "items";
+static char __pyx_k__label[] = "label";
+static char __pyx_k__lines[] = "lines";
static char __pyx_k__range[] = "range";
+static char __pyx_k__rules[] = "rules";
+static char __pyx_k__score[] = "score";
static char __pyx_k__split[] = "split";
static char __pyx_k__strip[] = "strip";
+static char __pyx_k__super[] = "super";
+static char __pyx_k__value[] = "value";
static char __pyx_k__config[] = "config";
-static char __pyx_k__decode[] = "decode";
+static char __pyx_k__csplit[] = "csplit";
static char __pyx_k__encode[] = "encode";
-static char __pyx_k__decoder[] = "decoder";
+static char __pyx_k__format[] = "format";
+static char __pyx_k__phrase[] = "phrase";
+static char __pyx_k__scores[] = "scores";
+static char __pyx_k__tagger[] = "tagger";
+static char __pyx_k__weight[] = "weight";
+static char __pyx_k___phrase[] = "_phrase";
+static char __pyx_k__density[] = "density";
+static char __pyx_k__genexpr[] = "genexpr";
static char __pyx_k__grammar[] = "grammar";
+static char __pyx_k__replace[] = "replace";
+static char __pyx_k__IBM_BLEU[] = "IBM_BLEU";
static char __pyx_k__KeyError[] = "KeyError";
static char __pyx_k____exit__[] = "__exit__";
+static char __pyx_k____init__[] = "__init__";
static char __pyx_k____main__[] = "__main__";
+static char __pyx_k____name__[] = "__name__";
static char __pyx_k____test__[] = "__test__";
+static char __pyx_k__encoding[] = "encoding";
+static char __pyx_k__evaluate[] = "evaluate";
+static char __pyx_k__in_edges[] = "in_edges";
+static char __pyx_k__lexalign[] = "lexalign";
+static char __pyx_k__lextrans[] = "lextrans";
static char __pyx_k__sentence[] = "sentence";
static char __pyx_k__Exception[] = "Exception";
+static char __pyx_k__TypeError[] = "TypeError";
+static char __pyx_k____class__[] = "__class__";
static char __pyx_k____enter__[] = "__enter__";
-static char __pyx_k__plf_tuple[] = "plf_tuple";
+static char __pyx_k__enumerate[] = "enumerate";
+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__beam_alpha[] = "beam_alpha";
+static char __pyx_k__config_str[] = "config_str";
+static char __pyx_k__hypergraph[] = "hypergraph";
+static char __pyx_k__startswith[] = "startswith";
static char __pyx_k__ParseFailed[] = "ParseFailed";
+static char __pyx_k__PhraseModel_[] = "PhraseModel_";
+static char __pyx_k___make_config[] = "_make_config";
+static char __pyx_k__InvalidConfig[] = "InvalidConfig";
+static char __pyx_k__NotImplemented[] = "NotImplemented";
+static PyObject *__pyx_kp_s_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_17;
+static PyObject *__pyx_kp_s_19;
+static PyObject *__pyx_kp_s_22;
+static PyObject *__pyx_kp_s_23;
+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_34;
+static PyObject *__pyx_kp_s_35;
+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_45;
+static PyObject *__pyx_kp_s_46;
+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_n_s_54;
+static PyObject *__pyx_n_s_55;
+static PyObject *__pyx_kp_s_58;
+static PyObject *__pyx_kp_s_64;
+static PyObject *__pyx_kp_s_7;
+static PyObject *__pyx_kp_s_8;
+static PyObject *__pyx_kp_s_9;
+static PyObject *__pyx_n_s__BLEU;
+static PyObject *__pyx_n_s__CER;
static PyObject *__pyx_n_s__Exception;
+static PyObject *__pyx_n_s__IBM_BLEU;
+static PyObject *__pyx_n_s__IndexError;
+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;
+static PyObject *__pyx_n_s____class__;
static PyObject *__pyx_n_s____enter__;
static PyObject *__pyx_n_s____exit__;
+static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____main__;
+static PyObject *__pyx_n_s____name__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___cdec;
+static PyObject *__pyx_n_s___make_config;
+static PyObject *__pyx_n_s___phrase;
+static PyObject *__pyx_n_s___sa;
+static PyObject *__pyx_n_s__a;
+static PyObject *__pyx_n_s__beam_alpha;
+static PyObject *__pyx_n_s__cat;
static PyObject *__pyx_n_s__config;
-static PyObject *__pyx_n_s__decode;
-static PyObject *__pyx_n_s__decoder;
+static PyObject *__pyx_n_s__config_str;
+static PyObject *__pyx_n_s__csplit;
+static PyObject *__pyx_n_s__delta;
+static PyObject *__pyx_n_s__density;
+static PyObject *__pyx_n_s__dot;
+static PyObject *__pyx_n_s__e;
static PyObject *__pyx_n_s__encode;
+static PyObject *__pyx_n_s__encoding;
+static PyObject *__pyx_n_s__enumerate;
static PyObject *__pyx_n_s__eval;
+static PyObject *__pyx_n_s__evaluate;
+static PyObject *__pyx_n_s__evaluator;
+static PyObject *__pyx_n_s__f;
+static PyObject *__pyx_n_s__formalism;
+static PyObject *__pyx_n_s__format;
+static PyObject *__pyx_n_s__fst;
+static PyObject *__pyx_n_s__genexpr;
+static PyObject *__pyx_n_s__get;
static PyObject *__pyx_n_s__grammar;
+static PyObject *__pyx_n_s__hyp;
+static PyObject *__pyx_n_s__hypergraph;
+static PyObject *__pyx_n_s__i;
+static PyObject *__pyx_n_s__in_edges;
+static PyObject *__pyx_n_s__info;
+static PyObject *__pyx_n_s__inp;
+static PyObject *__pyx_n_s__items;
+static PyObject *__pyx_n_s__join;
+static PyObject *__pyx_n_s__k;
+static PyObject *__pyx_n_s__key;
+static PyObject *__pyx_n_s__label;
+static PyObject *__pyx_n_s__lexalign;
+static PyObject *__pyx_n_s__lextrans;
+static PyObject *__pyx_n_s__lhs;
+static PyObject *__pyx_n_s__lines;
+static PyObject *__pyx_n_s__name;
static PyObject *__pyx_n_s__open;
-static PyObject *__pyx_n_s__plf_tuple;
+static PyObject *__pyx_n_s__pb;
+static PyObject *__pyx_n_s__phrase;
+static PyObject *__pyx_n_s__plf;
static PyObject *__pyx_n_s__range;
+static PyObject *__pyx_n_s__ref;
+static PyObject *__pyx_n_s__refs;
+static PyObject *__pyx_n_s__replace;
+static PyObject *__pyx_n_s__rhs;
+static PyObject *__pyx_n_s__rules;
+static PyObject *__pyx_n_s__scfg;
+static PyObject *__pyx_n_s__score;
+static PyObject *__pyx_n_s__scores;
static PyObject *__pyx_n_s__self;
static PyObject *__pyx_n_s__sentence;
+static PyObject *__pyx_n_s__span;
static PyObject *__pyx_n_s__split;
+static PyObject *__pyx_n_s__startswith;
static PyObject *__pyx_n_s__strip;
+static PyObject *__pyx_n_s__super;
+static PyObject *__pyx_n_s__tagger;
static PyObject *__pyx_n_s__utf8;
-static PyObject *__pyx_k_tuple_1;
+static PyObject *__pyx_n_s__value;
+static PyObject *__pyx_n_s__weight;
+static PyObject *__pyx_int_0;
+static PyObject *__pyx_int_1;
+static PyObject *__pyx_int_65536;
static PyObject *__pyx_k_tuple_2;
-static PyObject *__pyx_k_tuple_3;
-static PyObject *__pyx_k_tuple_4;
static PyObject *__pyx_k_tuple_5;
static PyObject *__pyx_k_tuple_6;
-static PyObject *__pyx_k_tuple_7;
+static PyObject *__pyx_k_tuple_14;
+static PyObject *__pyx_k_tuple_18;
+static PyObject *__pyx_k_tuple_20;
+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_51;
+static PyObject *__pyx_k_tuple_52;
+static PyObject *__pyx_k_tuple_56;
+static PyObject *__pyx_k_tuple_59;
+static PyObject *__pyx_k_tuple_60;
+static PyObject *__pyx_k_tuple_61;
+static PyObject *__pyx_k_tuple_62;
+static PyObject *__pyx_k_codeobj_37;
+static PyObject *__pyx_k_codeobj_57;
+static PyObject *__pyx_k_codeobj_63;
+
+/* "_cdec.pyx":6
+ * cimport decoder
+ *
+ * cdef char* as_str(data, char* error_msg='Cannot convert type %s to str'): # <<<<<<<<<<<<<<
+ * cdef bytes ret
+ * if isinstance(data, unicode):
+ */
-/* Python wrapper */
-static int __pyx_pw_5_cdec_7Weights_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_5_cdec_7Weights_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- struct __pyx_obj_5_cdec_Decoder *__pyx_v_decoder = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__decoder,0};
- int __pyx_r;
+static char *__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;
__Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- PyObject* values[1] = {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 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__decoder);
- if (likely(values[0])) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __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);
+ 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;
+ __Pyx_RefNannySetupContext("as_str", 0);
+ if (__pyx_optional_args) {
+ if (__pyx_optional_args->__pyx_n > 0) {
+ __pyx_v_error_msg = __pyx_optional_args->error_msg;
}
- __pyx_v_decoder = ((struct __pyx_obj_5_cdec_Decoder *)values[0]);
}
- 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[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
- __pyx_L3_error:;
- __Pyx_AddTraceback("_cdec.Weights.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_decoder), __pyx_ptype_5_cdec_Decoder, 1, "decoder", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_7Weights___cinit__(((struct __pyx_obj_5_cdec_Weights *)__pyx_v_self), __pyx_v_decoder);
+
+ /* "_cdec.pyx":8
+ * cdef char* as_str(data, char* error_msg='Cannot convert type %s to str'):
+ * cdef bytes ret
+ * if isinstance(data, unicode): # <<<<<<<<<<<<<<
+ * ret = data.encode('utf8')
+ * elif isinstance(data, str):
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)(&PyUnicode_Type)));
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_data, __pyx_t_1);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ if (__pyx_t_2) {
+
+ /* "_cdec.pyx":9
+ * cdef bytes ret
+ * if isinstance(data, unicode):
+ * ret = data.encode('utf8') # <<<<<<<<<<<<<<
+ * elif isinstance(data, str):
+ * ret = data
+ */
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_data, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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 = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_ret = ((PyObject*)__pyx_t_3);
+ __pyx_t_3 = 0;
+ goto __pyx_L3;
+ }
+
+ /* "_cdec.pyx":10
+ * if isinstance(data, unicode):
+ * ret = data.encode('utf8')
+ * elif isinstance(data, str): # <<<<<<<<<<<<<<
+ * ret = data
+ * else:
+ */
+ __pyx_t_3 = ((PyObject *)((PyObject*)(&PyString_Type)));
+ __Pyx_INCREF(__pyx_t_3);
+ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_data, __pyx_t_3);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ if (__pyx_t_2) {
+
+ /* "_cdec.pyx":11
+ * ret = data.encode('utf8')
+ * elif isinstance(data, str):
+ * ret = data # <<<<<<<<<<<<<<
+ * else:
+ * raise TypeError(error_msg.format(type(data)))
+ */
+ if (!(likely(PyBytes_CheckExact(__pyx_v_data))||((__pyx_v_data) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_data)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_INCREF(__pyx_v_data);
+ __pyx_v_ret = ((PyObject*)__pyx_v_data);
+ goto __pyx_L3;
+ }
+ /*else*/ {
+
+ /* "_cdec.pyx":13
+ * ret = data
+ * else:
+ * raise TypeError(error_msg.format(type(data))) # <<<<<<<<<<<<<<
+ * return ret
+ *
+ */
+ __pyx_t_3 = PyBytes_FromString(__pyx_v_error_msg); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+ __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_t_3), __pyx_n_s__format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_data)));
+ PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(__pyx_v_data)));
+ __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_data)));
+ __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
+ __Pyx_GIVEREF(__pyx_t_4);
+ __pyx_t_4 = 0;
+ __pyx_t_4 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __Pyx_Raise(__pyx_t_4, 0, 0, 0);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ __pyx_L3:;
+
+ /* "_cdec.pyx":14
+ * else:
+ * raise TypeError(error_msg.format(type(data)))
+ * return ret # <<<<<<<<<<<<<<
+ *
+ * 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;
+ goto __pyx_L0;
+
+ __pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
- __pyx_r = -1;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_WriteUnraisable("_cdec.as_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = 0;
__pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_ret);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "_cdec.pyx":18
- * cdef vector[weight_t]* weights
- *
- * def __cinit__(self, Decoder decoder): # <<<<<<<<<<<<<<
- * self.weights = &decoder.dec.CurrentWeightVector()
+/* Python wrapper */
+static int __pyx_pw_5_cdec_11DenseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5_cdec_11DenseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+ if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
+ __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
+ if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
+ __pyx_r = __pyx_pf_5_cdec_11DenseVector___init__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":7
+ * cdef bint owned # if True, do not manage memory
*
+ * def __init__(self): # <<<<<<<<<<<<<<
+ * self.vector = new vector[weight_t]()
+ * self.owned = False
*/
-static int __pyx_pf_5_cdec_7Weights___cinit__(struct __pyx_obj_5_cdec_Weights *__pyx_v_self, struct __pyx_obj_5_cdec_Decoder *__pyx_v_decoder) {
+static int __pyx_pf_5_cdec_11DenseVector___init__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) {
int __pyx_r;
__Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__", 0);
+ __Pyx_RefNannySetupContext("__init__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":8
+ *
+ * def __init__(self):
+ * self.vector = new vector[weight_t]() # <<<<<<<<<<<<<<
+ * self.owned = False
+ *
+ */
+ __pyx_v_self->vector = new std::vector<weight_t>();
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":9
+ * def __init__(self):
+ * self.vector = new vector[weight_t]()
+ * self.owned = False # <<<<<<<<<<<<<<
+ *
+ * def __dealloc__(self):
+ */
+ __pyx_v_self->owned = 0;
+
+ __pyx_r = 0;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static void __pyx_pw_5_cdec_11DenseVector_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_5_cdec_11DenseVector_3__dealloc__(PyObject *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+ __pyx_pf_5_cdec_11DenseVector_2__dealloc__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":11
+ * self.owned = False
+ *
+ * def __dealloc__(self): # <<<<<<<<<<<<<<
+ * if not self.owned:
+ * del self.vector
+ */
+
+static void __pyx_pf_5_cdec_11DenseVector_2__dealloc__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ int __pyx_t_1;
+ __Pyx_RefNannySetupContext("__dealloc__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":12
+ *
+ * def __dealloc__(self):
+ * if not self.owned: # <<<<<<<<<<<<<<
+ * del self.vector
+ *
+ */
+ __pyx_t_1 = (!__pyx_v_self->owned);
+ if (__pyx_t_1) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":13
+ * def __dealloc__(self):
+ * if not self.owned:
+ * del self.vector # <<<<<<<<<<<<<<
+ *
+ * def __len__(self):
+ */
+ delete __pyx_v_self->vector;
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ __Pyx_RefNannyFinishContext();
+}
+
+/* Python wrapper */
+static Py_ssize_t __pyx_pw_5_cdec_11DenseVector_5__len__(PyObject *__pyx_v_self); /*proto*/
+static Py_ssize_t __pyx_pw_5_cdec_11DenseVector_5__len__(PyObject *__pyx_v_self) {
+ Py_ssize_t __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_11DenseVector_4__len__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":15
+ * del self.vector
+ *
+ * def __len__(self): # <<<<<<<<<<<<<<
+ * return self.vector.size()
+ *
+ */
- /* "_cdec.pyx":19
+static Py_ssize_t __pyx_pf_5_cdec_11DenseVector_4__len__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) {
+ Py_ssize_t __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__len__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":16
*
- * def __cinit__(self, Decoder decoder):
- * self.weights = &decoder.dec.CurrentWeightVector() # <<<<<<<<<<<<<<
+ * def __len__(self):
+ * return self.vector.size() # <<<<<<<<<<<<<<
*
* def __getitem__(self, char* fname):
*/
- __pyx_v_self->weights = (&__pyx_v_decoder->dec->CurrentWeightVector());
+ __pyx_r = __pyx_v_self->vector->size();
+ goto __pyx_L0;
__pyx_r = 0;
+ __pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_7Weights_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname); /*proto*/
-static PyObject *__pyx_pw_5_cdec_7Weights_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname) {
+static PyObject *__pyx_pw_5_cdec_11DenseVector_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname); /*proto*/
+static PyObject *__pyx_pw_5_cdec_11DenseVector_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname) {
char *__pyx_v_fname;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
assert(__pyx_arg_fname); {
- __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
- __Pyx_AddTraceback("_cdec.Weights.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.DenseVector.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5_cdec_7Weights_2__getitem__(((struct __pyx_obj_5_cdec_Weights *)__pyx_v_self), ((char *)__pyx_v_fname));
+ __pyx_r = __pyx_pf_5_cdec_11DenseVector_6__getitem__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self), ((char *)__pyx_v_fname));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "_cdec.pyx":21
- * self.weights = &decoder.dec.CurrentWeightVector()
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":18
+ * return self.vector.size()
*
* def __getitem__(self, char* fname): # <<<<<<<<<<<<<<
- * cdef unsigned fid = FDConvert(fname)
- * if fid <= self.weights.size():
+ * cdef int fid = FDConvert(fname)
+ * if 0 <= fid < self.vector.size():
*/
-static PyObject *__pyx_pf_5_cdec_7Weights_2__getitem__(struct __pyx_obj_5_cdec_Weights *__pyx_v_self, char *__pyx_v_fname) {
- unsigned int __pyx_v_fid;
+static PyObject *__pyx_pf_5_cdec_11DenseVector_6__getitem__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, char *__pyx_v_fname) {
+ int __pyx_v_fid;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
@@ -916,34 +2514,37 @@ static PyObject *__pyx_pf_5_cdec_7Weights_2__getitem__(struct __pyx_obj_5_cdec_W
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__getitem__", 0);
- /* "_cdec.pyx":22
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":19
*
* def __getitem__(self, char* fname):
- * cdef unsigned fid = FDConvert(fname) # <<<<<<<<<<<<<<
- * if fid <= self.weights.size():
- * return self.weights[0][fid]
+ * cdef int fid = FDConvert(fname) # <<<<<<<<<<<<<<
+ * if 0 <= fid < self.vector.size():
+ * return self.vector[0][fid]
*/
__pyx_v_fid = FD::Convert(__pyx_v_fname);
- /* "_cdec.pyx":23
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":20
* def __getitem__(self, char* fname):
- * cdef unsigned fid = FDConvert(fname)
- * if fid <= self.weights.size(): # <<<<<<<<<<<<<<
- * return self.weights[0][fid]
+ * cdef int fid = FDConvert(fname)
+ * if 0 <= fid < self.vector.size(): # <<<<<<<<<<<<<<
+ * return self.vector[0][fid]
* raise KeyError(fname)
*/
- __pyx_t_1 = (__pyx_v_fid <= __pyx_v_self->weights->size());
+ __pyx_t_1 = (0 <= __pyx_v_fid);
+ if (__pyx_t_1) {
+ __pyx_t_1 = (__pyx_v_fid < __pyx_v_self->vector->size());
+ }
if (__pyx_t_1) {
- /* "_cdec.pyx":24
- * cdef unsigned fid = FDConvert(fname)
- * if fid <= self.weights.size():
- * return self.weights[0][fid] # <<<<<<<<<<<<<<
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":21
+ * cdef int fid = FDConvert(fname)
+ * if 0 <= fid < self.vector.size():
+ * return self.vector[0][fid] # <<<<<<<<<<<<<<
* raise KeyError(fname)
*
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = PyFloat_FromDouble(((__pyx_v_self->weights[0])[__pyx_v_fid])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyFloat_FromDouble(((__pyx_v_self->vector[0])[__pyx_v_fid])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
@@ -952,33 +2553,33 @@ static PyObject *__pyx_pf_5_cdec_7Weights_2__getitem__(struct __pyx_obj_5_cdec_W
}
__pyx_L3:;
- /* "_cdec.pyx":25
- * if fid <= self.weights.size():
- * return self.weights[0][fid]
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":22
+ * if 0 <= fid < self.vector.size():
+ * return self.vector[0][fid]
* raise KeyError(fname) # <<<<<<<<<<<<<<
*
* def __setitem__(self, char* fname, float value):
*/
- __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_2));
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
__Pyx_GIVEREF(((PyObject *)__pyx_t_2));
__pyx_t_2 = 0;
- __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
__Pyx_Raise(__pyx_t_2, 0, 0, 0);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("_cdec.Weights.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.DenseVector.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
@@ -987,111 +2588,149 @@ static PyObject *__pyx_pf_5_cdec_7Weights_2__getitem__(struct __pyx_obj_5_cdec_W
}
/* Python wrapper */
-static int __pyx_pw_5_cdec_7Weights_5__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname, PyObject *__pyx_arg_value); /*proto*/
-static int __pyx_pw_5_cdec_7Weights_5__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname, PyObject *__pyx_arg_value) {
+static int __pyx_pw_5_cdec_11DenseVector_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname, PyObject *__pyx_arg_value); /*proto*/
+static int __pyx_pw_5_cdec_11DenseVector_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname, PyObject *__pyx_arg_value) {
char *__pyx_v_fname;
float __pyx_v_value;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
assert(__pyx_arg_fname); {
- __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
assert(__pyx_arg_value); {
- __pyx_v_value = __pyx_PyFloat_AsFloat(__pyx_arg_value); if (unlikely((__pyx_v_value == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_value = __pyx_PyFloat_AsFloat(__pyx_arg_value); if (unlikely((__pyx_v_value == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
- __Pyx_AddTraceback("_cdec.Weights.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.DenseVector.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return -1;
__pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5_cdec_7Weights_4__setitem__(((struct __pyx_obj_5_cdec_Weights *)__pyx_v_self), ((char *)__pyx_v_fname), ((float)__pyx_v_value));
+ __pyx_r = __pyx_pf_5_cdec_11DenseVector_8__setitem__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self), ((char *)__pyx_v_fname), ((float)__pyx_v_value));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "_cdec.pyx":27
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":24
* raise KeyError(fname)
*
* def __setitem__(self, char* fname, float value): # <<<<<<<<<<<<<<
- * cdef unsigned fid = FDConvert(<char *>fname)
- * if self.weights.size() <= fid:
+ * cdef int fid = FDConvert(<char *>fname)
+ * if fid < 0: raise KeyError(fname)
*/
-static int __pyx_pf_5_cdec_7Weights_4__setitem__(struct __pyx_obj_5_cdec_Weights *__pyx_v_self, char *__pyx_v_fname, float __pyx_v_value) {
- unsigned int __pyx_v_fid;
+static int __pyx_pf_5_cdec_11DenseVector_8__setitem__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, char *__pyx_v_fname, float __pyx_v_value) {
+ int __pyx_v_fid;
int __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setitem__", 0);
- /* "_cdec.pyx":28
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":25
*
* def __setitem__(self, char* fname, float value):
- * cdef unsigned fid = FDConvert(<char *>fname) # <<<<<<<<<<<<<<
- * if self.weights.size() <= fid:
- * self.weights.resize(fid + 1)
+ * cdef int fid = FDConvert(<char *>fname) # <<<<<<<<<<<<<<
+ * if fid < 0: raise KeyError(fname)
+ * if self.vector.size() <= fid:
*/
__pyx_v_fid = FD::Convert(((char *)__pyx_v_fname));
- /* "_cdec.pyx":29
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":26
* def __setitem__(self, char* fname, float value):
- * cdef unsigned fid = FDConvert(<char *>fname)
- * if self.weights.size() <= fid: # <<<<<<<<<<<<<<
- * self.weights.resize(fid + 1)
- * self.weights[0][fid] = value
+ * cdef int fid = FDConvert(<char *>fname)
+ * if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<<
+ * if self.vector.size() <= fid:
+ * self.vector.resize(fid + 1)
*/
- __pyx_t_1 = (__pyx_v_self->weights->size() <= __pyx_v_fid);
+ __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_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_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_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;}
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
- /* "_cdec.pyx":30
- * cdef unsigned fid = FDConvert(<char *>fname)
- * if self.weights.size() <= fid:
- * self.weights.resize(fid + 1) # <<<<<<<<<<<<<<
- * self.weights[0][fid] = value
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":27
+ * cdef int fid = FDConvert(<char *>fname)
+ * if fid < 0: raise KeyError(fname)
+ * if self.vector.size() <= fid: # <<<<<<<<<<<<<<
+ * self.vector.resize(fid + 1)
+ * self.vector[0][fid] = value
+ */
+ __pyx_t_1 = (__pyx_v_self->vector->size() <= __pyx_v_fid);
+ if (__pyx_t_1) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":28
+ * if fid < 0: raise KeyError(fname)
+ * if self.vector.size() <= fid:
+ * self.vector.resize(fid + 1) # <<<<<<<<<<<<<<
+ * self.vector[0][fid] = value
*
*/
- __pyx_v_self->weights->resize((__pyx_v_fid + 1));
- goto __pyx_L3;
+ __pyx_v_self->vector->resize((__pyx_v_fid + 1));
+ goto __pyx_L4;
}
- __pyx_L3:;
+ __pyx_L4:;
- /* "_cdec.pyx":31
- * if self.weights.size() <= fid:
- * self.weights.resize(fid + 1)
- * self.weights[0][fid] = value # <<<<<<<<<<<<<<
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":29
+ * if self.vector.size() <= fid:
+ * self.vector.resize(fid + 1)
+ * self.vector[0][fid] = value # <<<<<<<<<<<<<<
*
* def __iter__(self):
*/
- ((__pyx_v_self->weights[0])[__pyx_v_fid]) = __pyx_v_value;
+ ((__pyx_v_self->vector[0])[__pyx_v_fid]) = __pyx_v_value;
__pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_2);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("_cdec.DenseVector.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_7Weights_8generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+static PyObject *__pyx_gb_5_cdec_11DenseVector_12generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_7Weights_7__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_7Weights_7__iter__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pw_5_cdec_11DenseVector_11__iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_11DenseVector_11__iter__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_7Weights_6__iter__(((struct __pyx_obj_5_cdec_Weights *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_11DenseVector_10__iter__(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "_cdec.pyx":33
- * self.weights[0][fid] = value
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":31
+ * self.vector[0][fid] = value
*
* def __iter__(self): # <<<<<<<<<<<<<<
* cdef unsigned fid
- * for fid in range(1, self.weights.size()):
+ * for fid in range(1, self.vector.size()):
*/
-static PyObject *__pyx_pf_5_cdec_7Weights_6__iter__(struct __pyx_obj_5_cdec_Weights *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_11DenseVector_10__iter__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) {
struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@@ -1109,7 +2748,7 @@ static PyObject *__pyx_pf_5_cdec_7Weights_6__iter__(struct __pyx_obj_5_cdec_Weig
__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_7Weights_8generator, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_11DenseVector_12generator, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -1118,7 +2757,7 @@ static PyObject *__pyx_pf_5_cdec_7Weights_6__iter__(struct __pyx_obj_5_cdec_Weig
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
- __Pyx_AddTraceback("_cdec.Weights.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.DenseVector.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_DECREF(((PyObject *)__pyx_cur_scope));
@@ -1127,7 +2766,7 @@ static PyObject *__pyx_pf_5_cdec_7Weights_6__iter__(struct __pyx_obj_5_cdec_Weig
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_7Weights_8generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+static PyObject *__pyx_gb_5_cdec_11DenseVector_12generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ *)__pyx_generator->closure);
PyObject *__pyx_r = NULL;
@@ -1146,31 +2785,31 @@ static PyObject *__pyx_gb_5_cdec_7Weights_8generator(__pyx_GeneratorObject *__py
return NULL;
}
__pyx_L3_first_run:;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- /* "_cdec.pyx":35
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":33
* def __iter__(self):
* cdef unsigned fid
- * for fid in range(1, self.weights.size()): # <<<<<<<<<<<<<<
- * yield FDConvert(fid).c_str(), self.weights[0][fid]
+ * for fid in range(1, self.vector.size()): # <<<<<<<<<<<<<<
+ * yield FDConvert(fid).c_str(), self.vector[0][fid]
*
*/
- __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->weights->size();
+ __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;
- /* "_cdec.pyx":36
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":34
* cdef unsigned fid
- * for fid in range(1, self.weights.size()):
- * yield FDConvert(fid).c_str(), self.weights[0][fid] # <<<<<<<<<<<<<<
+ * for fid in range(1, self.vector.size()):
+ * yield FDConvert(fid).c_str(), self.vector[0][fid] # <<<<<<<<<<<<<<
*
- * cdef class Decoder:
+ * 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[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyBytes_FromString(FD::Convert(__pyx_cur_scope->__pyx_v_fid).c_str()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
- __pyx_t_4 = PyFloat_FromDouble(((__pyx_cur_scope->__pyx_v_self->weights[0])[__pyx_cur_scope->__pyx_v_fid])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyFloat_FromDouble(((__pyx_cur_scope->__pyx_v_self->vector[0])[__pyx_cur_scope->__pyx_v_fid])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_3));
__Pyx_GIVEREF(((PyObject *)__pyx_t_3));
@@ -1190,7 +2829,7 @@ static PyObject *__pyx_gb_5_cdec_7Weights_8generator(__pyx_GeneratorObject *__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[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
@@ -1202,24 +2841,2033 @@ static PyObject *__pyx_gb_5_cdec_7Weights_8generator(__pyx_GeneratorObject *__py
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
/* Python wrapper */
-static int __pyx_pw_5_cdec_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) {
- char *__pyx_v_config;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__config,0};
+static PyObject *__pyx_pw_5_cdec_11DenseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
+static PyObject *__pyx_pw_5_cdec_11DenseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("dot (wrapper)", 0);
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_11DenseVector_13dot(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other));
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":36
+ * yield FDConvert(fid).c_str(), self.vector[0][fid]
+ *
+ * def dot(self, SparseVector other): # <<<<<<<<<<<<<<
+ * 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) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("dot", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":37
+ *
+ * def dot(self, SparseVector other):
+ * 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_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_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_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+ __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_2);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("_cdec.DenseVector.dot", __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_11DenseVector_16tosparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5_cdec_11DenseVector_16tosparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("tosparse (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_11DenseVector_15tosparse(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":39
+ * return other.dot(self)
+ *
+ * def tosparse(self): # <<<<<<<<<<<<<<
+ * 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) {
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_sparse = 0;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("tosparse", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":40
+ *
+ * def tosparse(self):
+ * 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_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_sparse = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":41
+ * def tosparse(self):
+ * cdef SparseVector sparse = SparseVector.__new__(SparseVector)
+ * sparse.vector = new FastSparseVector[weight_t]() # <<<<<<<<<<<<<<
+ * InitSparseVector(self.vector[0], sparse.vector)
+ * return sparse
+ */
+ __pyx_v_sparse->vector = new FastSparseVector<weight_t>();
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":42
+ * cdef SparseVector sparse = SparseVector.__new__(SparseVector)
+ * sparse.vector = new FastSparseVector[weight_t]()
+ * InitSparseVector(self.vector[0], sparse.vector) # <<<<<<<<<<<<<<
+ * return sparse
+ *
+ */
+ Weights::InitSparseVector((__pyx_v_self->vector[0]), __pyx_v_sparse->vector);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":43
+ * sparse.vector = new FastSparseVector[weight_t]()
+ * InitSparseVector(self.vector[0], sparse.vector)
+ * return sparse # <<<<<<<<<<<<<<
+ *
+ * cdef class SparseVector:
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_sparse));
+ __pyx_r = ((PyObject *)__pyx_v_sparse);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.DenseVector.tosparse", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_sparse);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_12SparseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5_cdec_12SparseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
int __pyx_r;
__Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
+ __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+ if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
+ __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
+ if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector___init__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":48
+ * cdef FastSparseVector[weight_t]* vector
+ *
+ * def __init__(self): # <<<<<<<<<<<<<<
+ * self.vector = new FastSparseVector[weight_t]()
+ *
+ */
+
+static int __pyx_pf_5_cdec_12SparseVector___init__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__init__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":49
+ *
+ * def __init__(self):
+ * self.vector = new FastSparseVector[weight_t]() # <<<<<<<<<<<<<<
+ *
+ * def __dealloc__(self):
+ */
+ __pyx_v_self->vector = new FastSparseVector<weight_t>();
+
+ __pyx_r = 0;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static void __pyx_pw_5_cdec_12SparseVector_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_5_cdec_12SparseVector_3__dealloc__(PyObject *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+ __pyx_pf_5_cdec_12SparseVector_2__dealloc__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":51
+ * self.vector = new FastSparseVector[weight_t]()
+ *
+ * def __dealloc__(self): # <<<<<<<<<<<<<<
+ * del self.vector
+ *
+ */
+
+static void __pyx_pf_5_cdec_12SparseVector_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":52
+ *
+ * def __dealloc__(self):
+ * del self.vector # <<<<<<<<<<<<<<
+ *
+ * def copy(self):
+ */
+ delete __pyx_v_self->vector;
+
+ __Pyx_RefNannyFinishContext();
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_12SparseVector_5copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_5copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("copy (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_4copy(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":54
+ * del self.vector
+ *
+ * def copy(self): # <<<<<<<<<<<<<<
+ * return self * 1
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_12SparseVector_4copy(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("copy", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":55
+ *
+ * def copy(self):
+ * 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_GOTREF(__pyx_t_1);
+ __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_AddTraceback("_cdec.SparseVector.copy", __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_12SparseVector_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname) {
+ char *__pyx_v_fname;
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
+ assert(__pyx_arg_fname); {
+ __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("_cdec.SparseVector.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_6__getitem__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((char *)__pyx_v_fname));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":57
+ * return self * 1
+ *
+ * def __getitem__(self, char* fname): # <<<<<<<<<<<<<<
+ * cdef int fid = FDConvert(fname)
+ * if fid < 0: raise KeyError(fname)
+ */
+
+static PyObject *__pyx_pf_5_cdec_12SparseVector_6__getitem__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname) {
+ int __pyx_v_fid;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ int __pyx_t_1;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__getitem__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":58
+ *
+ * def __getitem__(self, char* fname):
+ * cdef int fid = FDConvert(fname) # <<<<<<<<<<<<<<
+ * if fid < 0: raise KeyError(fname)
+ * return self.vector.value(fid)
+ */
+ __pyx_v_fid = FD::Convert(__pyx_v_fname);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":59
+ * def __getitem__(self, char* fname):
+ * cdef int fid = FDConvert(fname)
+ * if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<<
+ * return self.vector.value(fid)
+ *
+ */
+ __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_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_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_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;}
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":60
+ * cdef int fid = FDConvert(fname)
+ * if fid < 0: raise KeyError(fname)
+ * return self.vector.value(fid) # <<<<<<<<<<<<<<
+ *
+ * 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_GOTREF(__pyx_t_2);
+ __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_2);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("_cdec.SparseVector.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_12SparseVector_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname, PyObject *__pyx_arg_value); /*proto*/
+static int __pyx_pw_5_cdec_12SparseVector_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname, PyObject *__pyx_arg_value) {
+ char *__pyx_v_fname;
+ float __pyx_v_value;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
+ assert(__pyx_arg_fname); {
+ __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ assert(__pyx_arg_value); {
+ __pyx_v_value = __pyx_PyFloat_AsFloat(__pyx_arg_value); if (unlikely((__pyx_v_value == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("_cdec.SparseVector.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return -1;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_8__setitem__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((char *)__pyx_v_fname), ((float)__pyx_v_value));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":62
+ * return self.vector.value(fid)
+ *
+ * def __setitem__(self, char* fname, float value): # <<<<<<<<<<<<<<
+ * cdef int fid = FDConvert(<char *>fname)
+ * if fid < 0: raise KeyError(fname)
+ */
+
+static int __pyx_pf_5_cdec_12SparseVector_8__setitem__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname, float __pyx_v_value) {
+ int __pyx_v_fid;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ int __pyx_t_1;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__setitem__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":63
+ *
+ * def __setitem__(self, char* fname, float value):
+ * cdef int fid = FDConvert(<char *>fname) # <<<<<<<<<<<<<<
+ * if fid < 0: raise KeyError(fname)
+ * self.vector.set_value(fid, value)
+ */
+ __pyx_v_fid = FD::Convert(((char *)__pyx_v_fname));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":64
+ * def __setitem__(self, char* fname, float value):
+ * cdef int fid = FDConvert(<char *>fname)
+ * if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<<
+ * 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_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_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_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;}
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":65
+ * cdef int fid = FDConvert(<char *>fname)
+ * if fid < 0: raise KeyError(fname)
+ * self.vector.set_value(fid, value) # <<<<<<<<<<<<<<
+ *
+ * def __iter__(self):
+ */
+ __pyx_v_self->vector->set_value(__pyx_v_fid, __pyx_v_value);
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_2);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("_cdec.SparseVector.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_12SparseVector_11__iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_11__iter__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_10__iter__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":67
+ * self.vector.set_value(fid, value)
+ *
+ * def __iter__(self): # <<<<<<<<<<<<<<
+ * cdef FastSparseVector[weight_t].const_iterator* it = new FastSparseVector[weight_t].const_iterator(self.vector[0], False)
+ * cdef unsigned i
+ */
+
+static PyObject *__pyx_pf_5_cdec_12SparseVector_10__iter__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ *__pyx_cur_scope;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ 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_1___iter__ *)__pyx_ptype_5_cdec___pyx_scope_struct_1___iter__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_1___iter__, __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);
{
- PyObject* values[1] = {0};
+ __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_12SparseVector_12generator1, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_cur_scope);
+ __Pyx_RefNannyFinishContext();
+ return (PyObject *) gen;
+ }
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.SparseVector.__iter__", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+ struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ *)__pyx_generator->closure);
+ PyObject *__pyx_r = NULL;
+ size_t __pyx_t_1;
+ unsigned int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ 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[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":68
+ *
+ * def __iter__(self):
+ * cdef FastSparseVector[weight_t].const_iterator* it = new FastSparseVector[weight_t].const_iterator(self.vector[0], False) # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * try:
+ */
+ __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
+ * 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)
+ */
+ /*try:*/ {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":71
+ * cdef unsigned i
+ * try:
+ * for i in range(self.vector.size()): # <<<<<<<<<<<<<<
+ * yield (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
+ * try:
+ * for i in range(self.vector.size()):
+ * yield (FDConvert(it[0].ptr().first).c_str(), it[0].ptr().second) # <<<<<<<<<<<<<<
+ * pinc(it[0]) # ++it
+ * finally:
+ */
+ __pyx_t_3 = PyBytes_FromString(FD::Convert((__pyx_cur_scope->__pyx_v_it[0]).operator->()->first).c_str()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+ __pyx_t_4 = PyFloat_FromDouble((__pyx_cur_scope->__pyx_v_it[0]).operator->()->second); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;}
+ __Pyx_GOTREF(__pyx_t_5);
+ PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_3));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
+ PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
+ __Pyx_GIVEREF(__pyx_t_4);
+ __pyx_t_3 = 0;
+ __pyx_t_4 = 0;
+ __pyx_r = ((PyObject *)__pyx_t_5);
+ __pyx_t_5 = 0;
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __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_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;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":73
+ * for i in range(self.vector.size()):
+ * yield (FDConvert(it[0].ptr().first).c_str(), it[0].ptr().second)
+ * pinc(it[0]) # ++it # <<<<<<<<<<<<<<
+ * finally:
+ * del it
+ */
+ (++(__pyx_cur_scope->__pyx_v_it[0]));
+ }
+ }
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":75
+ * pinc(it[0]) # ++it
+ * finally:
+ * del it # <<<<<<<<<<<<<<
+ *
+ * def dot(self, other):
+ */
+ /*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_3); __pyx_t_3 = 0;
+ __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 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_it;
+ 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_3);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_XDECREF(__pyx_t_5);
+ __Pyx_AddTraceback("__iter__", __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_12SparseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("dot (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_13dot(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((PyObject *)__pyx_v_other));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":77
+ * del it
+ *
+ * def dot(self, other): # <<<<<<<<<<<<<<
+ * 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) {
+ 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("dot", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":78
+ *
+ * def dot(self, other):
+ * if isinstance(other, DenseVector): # <<<<<<<<<<<<<<
+ * return self.vector.dot((<DenseVector> other).vector[0])
+ * elif isinstance(other, SparseVector):
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_DenseVector));
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_other, __pyx_t_1);
+ __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):
+ * 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_GOTREF(__pyx_t_1);
+ __pyx_r = __pyx_t_1;
+ __pyx_t_1 = 0;
+ goto __pyx_L0;
+ goto __pyx_L3;
+ }
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":80
+ * if isinstance(other, DenseVector):
+ * return self.vector.dot((<DenseVector> other).vector[0])
+ * elif isinstance(other, SparseVector): # <<<<<<<<<<<<<<
+ * return self.vector.dot((<SparseVector> other).vector[0])
+ * raise TypeError('cannot take the dot product of %s and SparseVector' % type(other))
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector));
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_other, __pyx_t_1);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ if (__pyx_t_2) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":81
+ * return self.vector.dot((<DenseVector> other).vector[0])
+ * elif isinstance(other, SparseVector):
+ * return self.vector.dot((<SparseVector> other).vector[0]) # <<<<<<<<<<<<<<
+ * raise TypeError('cannot take the dot product of %s and SparseVector' % type(other))
+ *
+ */
+ __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_GOTREF(__pyx_t_1);
+ __pyx_r = __pyx_t_1;
+ __pyx_t_1 = 0;
+ goto __pyx_L0;
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":82
+ * elif isinstance(other, SparseVector):
+ * return self.vector.dot((<SparseVector> other).vector[0])
+ * raise TypeError('cannot take the dot product of %s and SparseVector' % type(other)) # <<<<<<<<<<<<<<
+ *
+ * def __richcmp__(SparseVector x, SparseVector y, int op):
+ */
+ __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), ((PyObject *)Py_TYPE(__pyx_v_other))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+ __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ {__pyx_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ __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.SparseVector.dot", __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_12SparseVector_16__richcmp__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_16__richcmp__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_15__richcmp__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y), ((int)__pyx_v_op));
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":84
+ * raise TypeError('cannot take the dot product of %s and SparseVector' % type(other))
+ *
+ * def __richcmp__(SparseVector x, SparseVector y, int op): # <<<<<<<<<<<<<<
+ * if op == 2: # ==
+ * return x.vector[0] == y.vector[0]
+ */
+
+static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y, int __pyx_v_op) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_t_2;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__richcmp__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":87
+ * if op == 2: # ==
+ * return x.vector[0] == y.vector[0]
+ * elif op == 3: # != # <<<<<<<<<<<<<<
+ * return not (x == y)
+ * raise NotImplemented('comparison not implemented for SparseVector')
+ */
+ switch (__pyx_v_op) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":85
+ *
+ * def __richcmp__(SparseVector x, SparseVector y, int op):
+ * if op == 2: # == # <<<<<<<<<<<<<<
+ * return x.vector[0] == y.vector[0]
+ * elif op == 3: # !=
+ */
+ case 2:
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":86
+ * def __richcmp__(SparseVector x, SparseVector y, int op):
+ * if op == 2: # ==
+ * return x.vector[0] == y.vector[0] # <<<<<<<<<<<<<<
+ * elif op == 3: # !=
+ * 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_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
+ * if op == 2: # ==
+ * return x.vector[0] == y.vector[0]
+ * elif op == 3: # != # <<<<<<<<<<<<<<
+ * return not (x == y)
+ * raise NotImplemented('comparison not implemented for SparseVector')
+ */
+ case 3:
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":88
+ * return x.vector[0] == y.vector[0]
+ * elif op == 3: # !=
+ * return not (x == y) # <<<<<<<<<<<<<<
+ * raise NotImplemented('comparison not implemented for SparseVector')
+ *
+ */
+ __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_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_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":89
+ * elif op == 3: # !=
+ * return not (x == y)
+ * raise NotImplemented('comparison not implemented for SparseVector') # <<<<<<<<<<<<<<
+ *
+ * def __len__(self):
+ */
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.SparseVector.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static Py_ssize_t __pyx_pw_5_cdec_12SparseVector_18__len__(PyObject *__pyx_v_self); /*proto*/
+static Py_ssize_t __pyx_pw_5_cdec_12SparseVector_18__len__(PyObject *__pyx_v_self) {
+ Py_ssize_t __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_17__len__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":91
+ * raise NotImplemented('comparison not implemented for SparseVector')
+ *
+ * def __len__(self): # <<<<<<<<<<<<<<
+ * return self.vector.size()
+ *
+ */
+
+static Py_ssize_t __pyx_pf_5_cdec_12SparseVector_17__len__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
+ Py_ssize_t __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__len__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":92
+ *
+ * def __len__(self):
+ * return self.vector.size() # <<<<<<<<<<<<<<
+ *
+ * def __contains__(self, char* fname):
+ */
+ __pyx_r = __pyx_v_self->vector->size();
+ goto __pyx_L0;
+
+ __pyx_r = 0;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_12SparseVector_20__contains__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname); /*proto*/
+static int __pyx_pw_5_cdec_12SparseVector_20__contains__(PyObject *__pyx_v_self, PyObject *__pyx_arg_fname) {
+ char *__pyx_v_fname;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
+ assert(__pyx_arg_fname); {
+ __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("_cdec.SparseVector.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return -1;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_19__contains__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((char *)__pyx_v_fname));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":94
+ * return self.vector.size()
+ *
+ * def __contains__(self, char* fname): # <<<<<<<<<<<<<<
+ * return self.vector.nonzero(FDConvert(fname))
+ *
+ */
+
+static int __pyx_pf_5_cdec_12SparseVector_19__contains__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__contains__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":95
+ *
+ * def __contains__(self, char* fname):
+ * return self.vector.nonzero(FDConvert(fname)) # <<<<<<<<<<<<<<
+ *
+ * def __neg__(self):
+ */
+ __pyx_r = __pyx_v_self->vector->nonzero(FD::Convert(__pyx_v_fname));
+ goto __pyx_L0;
+
+ __pyx_r = 0;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_12SparseVector_22__neg__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_22__neg__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__neg__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_21__neg__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":97
+ * return self.vector.nonzero(FDConvert(fname))
+ *
+ * def __neg__(self): # <<<<<<<<<<<<<<
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
+ * result.vector = new FastSparseVector[weight_t](self.vector[0])
+ */
+
+static PyObject *__pyx_pf_5_cdec_12SparseVector_21__neg__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_result = 0;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__neg__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":98
+ *
+ * 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_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":99
+ * def __neg__(self):
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
+ * result.vector = new FastSparseVector[weight_t](self.vector[0]) # <<<<<<<<<<<<<<
+ * result.vector[0] *= -1.0
+ * return result
+ */
+ __pyx_v_result->vector = new FastSparseVector<weight_t>((__pyx_v_self->vector[0]));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":100
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
+ * result.vector = new FastSparseVector[weight_t](self.vector[0])
+ * result.vector[0] *= -1.0 # <<<<<<<<<<<<<<
+ * return result
+ *
+ */
+ (__pyx_v_result->vector[0]) *= -1.0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":101
+ * result.vector = new FastSparseVector[weight_t](self.vector[0])
+ * result.vector[0] *= -1.0
+ * return result # <<<<<<<<<<<<<<
+ *
+ * def __iadd__(SparseVector self, SparseVector other):
+ */
+ __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_AddTraceback("_cdec.SparseVector.__neg__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_result);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_12SparseVector_24__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_24__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__iadd__ (wrapper)", 0);
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_23__iadd__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other));
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":103
+ * return result
+ *
+ * def __iadd__(SparseVector self, SparseVector other): # <<<<<<<<<<<<<<
+ * self.vector[0] += other.vector[0]
+ * return self
+ */
+
+static PyObject *__pyx_pf_5_cdec_12SparseVector_23__iadd__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__iadd__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":104
+ *
+ * def __iadd__(SparseVector self, SparseVector other):
+ * self.vector[0] += other.vector[0] # <<<<<<<<<<<<<<
+ * return self
+ *
+ */
+ (__pyx_v_self->vector[0]) += (__pyx_v_other->vector[0]);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":105
+ * def __iadd__(SparseVector self, SparseVector other):
+ * self.vector[0] += other.vector[0]
+ * return self # <<<<<<<<<<<<<<
+ *
+ * def __isub__(SparseVector self, SparseVector other):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_self));
+ __pyx_r = ((PyObject *)__pyx_v_self);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_12SparseVector_26__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_26__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__isub__ (wrapper)", 0);
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_25__isub__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other));
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":107
+ * return self
+ *
+ * def __isub__(SparseVector self, SparseVector other): # <<<<<<<<<<<<<<
+ * self.vector[0] -= other.vector[0]
+ * return self
+ */
+
+static PyObject *__pyx_pf_5_cdec_12SparseVector_25__isub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__isub__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":108
+ *
+ * def __isub__(SparseVector self, SparseVector other):
+ * self.vector[0] -= other.vector[0] # <<<<<<<<<<<<<<
+ * return self
+ *
+ */
+ (__pyx_v_self->vector[0]) -= (__pyx_v_other->vector[0]);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":109
+ * def __isub__(SparseVector self, SparseVector other):
+ * self.vector[0] -= other.vector[0]
+ * return self # <<<<<<<<<<<<<<
+ *
+ * def __imul__(SparseVector self, float scalar):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_self));
+ __pyx_r = ((PyObject *)__pyx_v_self);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_12SparseVector_28__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_28__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar) {
+ float __pyx_v_scalar;
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__imul__ (wrapper)", 0);
+ assert(__pyx_arg_scalar); {
+ __pyx_v_scalar = __pyx_PyFloat_AsFloat(__pyx_arg_scalar); if (unlikely((__pyx_v_scalar == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("_cdec.SparseVector.__imul__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_27__imul__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((float)__pyx_v_scalar));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":111
+ * return self
+ *
+ * def __imul__(SparseVector self, float scalar): # <<<<<<<<<<<<<<
+ * self.vector[0] *= scalar
+ * return self
+ */
+
+static PyObject *__pyx_pf_5_cdec_12SparseVector_27__imul__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__imul__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":112
+ *
+ * def __imul__(SparseVector self, float scalar):
+ * self.vector[0] *= scalar # <<<<<<<<<<<<<<
+ * return self
+ *
+ */
+ (__pyx_v_self->vector[0]) *= __pyx_v_scalar;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":113
+ * def __imul__(SparseVector self, float scalar):
+ * self.vector[0] *= scalar
+ * return self # <<<<<<<<<<<<<<
+ *
+ * def __idiv__(SparseVector self, float scalar):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_self));
+ __pyx_r = ((PyObject *)__pyx_v_self);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+#if PY_MAJOR_VERSION < 3
+static PyObject *__pyx_pw_5_cdec_12SparseVector_30__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_30__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar) {
+ float __pyx_v_scalar;
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__idiv__ (wrapper)", 0);
+ assert(__pyx_arg_scalar); {
+ __pyx_v_scalar = __pyx_PyFloat_AsFloat(__pyx_arg_scalar); if (unlikely((__pyx_v_scalar == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("_cdec.SparseVector.__idiv__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_29__idiv__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((float)__pyx_v_scalar));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+#endif /*!(#if PY_MAJOR_VERSION < 3)*/
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":115
+ * return self
+ *
+ * def __idiv__(SparseVector self, float scalar): # <<<<<<<<<<<<<<
+ * self.vector[0] /= scalar
+ * return self
+ */
+
+#if PY_MAJOR_VERSION < 3
+static PyObject *__pyx_pf_5_cdec_12SparseVector_29__idiv__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__idiv__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":116
+ *
+ * def __idiv__(SparseVector self, float scalar):
+ * self.vector[0] /= scalar # <<<<<<<<<<<<<<
+ * return self
+ *
+ */
+ (__pyx_v_self->vector[0]) /= __pyx_v_scalar;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":117
+ * def __idiv__(SparseVector self, float scalar):
+ * self.vector[0] /= scalar
+ * return self # <<<<<<<<<<<<<<
+ *
+ * def __add__(SparseVector x, SparseVector y):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_self));
+ __pyx_r = ((PyObject *)__pyx_v_self);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+#endif /*!(#if PY_MAJOR_VERSION < 3)*/
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_12SparseVector_32__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_32__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_31__add__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y));
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":119
+ * return self
+ *
+ * def __add__(SparseVector x, SparseVector y): # <<<<<<<<<<<<<<
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
+ * result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0])
+ */
+
+static PyObject *__pyx_pf_5_cdec_12SparseVector_31__add__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y) {
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_result = 0;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__add__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":120
+ *
+ * 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_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":121
+ * 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_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
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
+ * result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0])
+ * return result # <<<<<<<<<<<<<<
+ *
+ * def __sub__(SparseVector x, SparseVector y):
+ */
+ __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_AddTraceback("_cdec.SparseVector.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_result);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_12SparseVector_34__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_34__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__sub__ (wrapper)", 0);
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_33__sub__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y));
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":124
+ * return result
+ *
+ * def __sub__(SparseVector x, SparseVector y): # <<<<<<<<<<<<<<
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
+ * result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0])
+ */
+
+static PyObject *__pyx_pf_5_cdec_12SparseVector_33__sub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y) {
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_result = 0;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__sub__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":125
+ *
+ * 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_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":126
+ * 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_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
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
+ * result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0])
+ * return result # <<<<<<<<<<<<<<
+ *
+ * def __mul__(x, y):
+ */
+ __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_AddTraceback("_cdec.SparseVector.__sub__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_result);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_12SparseVector_36__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_36__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__mul__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_35__mul__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":129
+ * return result
+ *
+ * def __mul__(x, y): # <<<<<<<<<<<<<<
+ * cdef SparseVector vector
+ * cdef float scalar
+ */
+
+static PyObject *__pyx_pf_5_cdec_12SparseVector_35__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_vector = 0;
+ float __pyx_v_scalar;
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_result = 0;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_t_2;
+ float __pyx_t_3;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__mul__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":132
+ * cdef SparseVector vector
+ * cdef float scalar
+ * if isinstance(x, SparseVector): vector, scalar = x, y # <<<<<<<<<<<<<<
+ * else: vector, scalar = y, x
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector));
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_x, __pyx_t_1);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ if (__pyx_t_2) {
+ if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __pyx_v_x;
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_y); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
+ __pyx_t_1 = 0;
+ __pyx_v_scalar = __pyx_t_3;
+ goto __pyx_L3;
+ }
+ /*else*/ {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":133
+ * cdef float scalar
+ * if isinstance(x, SparseVector): vector, scalar = x, y
+ * else: vector, scalar = y, x # <<<<<<<<<<<<<<
+ * cdef SparseVector result = SparseVector.__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;}
+ __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_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
+ * 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_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":135
+ * else: vector, scalar = y, x
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
+ * result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar) # <<<<<<<<<<<<<<
+ * return result
+ *
+ */
+ __pyx_v_result->vector = new FastSparseVector<weight_t>(((__pyx_v_vector->vector[0]) * __pyx_v_scalar));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":136
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
+ * result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar)
+ * return result # <<<<<<<<<<<<<<
+ *
+ * def __div__(x, y):
+ */
+ __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_AddTraceback("_cdec.SparseVector.__mul__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_vector);
+ __Pyx_XDECREF((PyObject *)__pyx_v_result);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+#if PY_MAJOR_VERSION < 3
+static PyObject *__pyx_pw_5_cdec_12SparseVector_38__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_38__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__div__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_37__div__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+#endif /*!(#if PY_MAJOR_VERSION < 3)*/
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":138
+ * return result
+ *
+ * def __div__(x, y): # <<<<<<<<<<<<<<
+ * cdef SparseVector vector
+ * cdef float scalar
+ */
+
+#if PY_MAJOR_VERSION < 3
+static PyObject *__pyx_pf_5_cdec_12SparseVector_37__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_vector = 0;
+ float __pyx_v_scalar;
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_result = 0;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_t_2;
+ float __pyx_t_3;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__div__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":141
+ * cdef SparseVector vector
+ * cdef float scalar
+ * if isinstance(x, SparseVector): vector, scalar = x, y # <<<<<<<<<<<<<<
+ * else: vector, scalar = y, x
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector));
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_x, __pyx_t_1);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ if (__pyx_t_2) {
+ if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __pyx_v_x;
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_y); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
+ __pyx_t_1 = 0;
+ __pyx_v_scalar = __pyx_t_3;
+ goto __pyx_L3;
+ }
+ /*else*/ {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":142
+ * cdef float scalar
+ * if isinstance(x, SparseVector): vector, scalar = x, y
+ * else: vector, scalar = y, x # <<<<<<<<<<<<<<
+ * cdef SparseVector result = SparseVector.__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;}
+ __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_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
+ * 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_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":144
+ * else: vector, scalar = y, x
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
+ * result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar) # <<<<<<<<<<<<<<
+ * return result
+ */
+ __pyx_v_result->vector = new FastSparseVector<weight_t>(((__pyx_v_vector->vector[0]) / __pyx_v_scalar));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":145
+ * cdef SparseVector result = SparseVector.__new__(SparseVector)
+ * result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar)
+ * 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_AddTraceback("_cdec.SparseVector.__div__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_vector);
+ __Pyx_XDECREF((PyObject *)__pyx_v_result);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+#endif /*!(#if PY_MAJOR_VERSION < 3)*/
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_1_phrase(PyObject *__pyx_self, PyObject *__pyx_v_phrase); /*proto*/
+static PyMethodDef __pyx_mdef_5_cdec_1_phrase = {__Pyx_NAMESTR("_phrase"), (PyCFunction)__pyx_pw_5_cdec_1_phrase, METH_O, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pw_5_cdec_1_phrase(PyObject *__pyx_self, PyObject *__pyx_v_phrase) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("_phrase (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec__phrase(__pyx_self, ((PyObject *)__pyx_v_phrase));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+static PyObject *__pyx_gb_5_cdec_7_phrase_2generator17(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":6
+ *
+ * def _phrase(phrase):
+ * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) # <<<<<<<<<<<<<<
+ *
+ * cdef class NT:
+ */
+
+static PyObject *__pyx_pf_5_cdec_7_phrase_genexpr(PyObject *__pyx_self) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_3_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_3_genexpr *)__pyx_ptype_5_cdec___pyx_scope_struct_3_genexpr->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_3_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_2__phrase *) __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_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._phrase.genexpr", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_7_phrase_2generator17(__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;
+ PyObject *__pyx_t_1 = NULL;
+ Py_ssize_t __pyx_t_2;
+ PyObject *(*__pyx_t_3)(PyObject *);
+ PyObject *__pyx_t_4 = NULL;
+ PyObject *__pyx_t_5 = NULL;
+ int __pyx_t_6;
+ PyObject *__pyx_t_7 = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("None", 0);
+ switch (__pyx_generator->resume_label) {
+ case 0: goto __pyx_L3_first_run;
+ case 1: goto __pyx_L6_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[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_phrase)) { __Pyx_RaiseClosureNameError("phrase"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
+ if (PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_phrase) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_phrase)) {
+ __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_phrase; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+ __pyx_t_3 = NULL;
+ } else {
+ __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_phrase); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
+ }
+ for (;;) {
+ if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
+ #else
+ __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
+ #else
+ __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_4 = __pyx_t_3(__pyx_t_1);
+ if (unlikely(!__pyx_t_4)) {
+ if (PyErr_Occurred()) {
+ if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
+ else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_4);
+ }
+ __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_w);
+ __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_w);
+ __Pyx_GIVEREF(__pyx_t_4);
+ __pyx_cur_scope->__pyx_v_w = __pyx_t_4;
+ __pyx_t_4 = 0;
+ __pyx_t_5 = ((PyObject *)((PyObject*)(&PyUnicode_Type)));
+ __Pyx_INCREF(__pyx_t_5);
+ __pyx_t_6 = __Pyx_TypeCheck(__pyx_cur_scope->__pyx_v_w, __pyx_t_5);
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ if (__pyx_t_6) {
+ __pyx_t_5 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_w, __pyx_n_s__encode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_7);
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __pyx_t_4 = __pyx_t_7;
+ __pyx_t_7 = 0;
+ } else {
+ __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_7);
+ __Pyx_INCREF(__pyx_cur_scope->__pyx_v_w);
+ PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_cur_scope->__pyx_v_w);
+ __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_w);
+ __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
+ __pyx_t_4 = __pyx_t_5;
+ __pyx_t_5 = 0;
+ }
+ __pyx_r = __pyx_t_4;
+ __pyx_t_4 = 0;
+ __Pyx_XGIVEREF(__pyx_t_1);
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 1;
+ return __pyx_r;
+ __pyx_L6_resume_from_yield:;
+ __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
+ __pyx_cur_scope->__pyx_t_0 = 0;
+ __Pyx_XGOTREF(__pyx_t_1);
+ __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
+ __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ PyErr_SetNone(PyExc_StopIteration);
+ 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_7);
+ __Pyx_AddTraceback("genexpr", __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;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5
+ * import cdec.sa._sa as _sa
+ *
+ * def _phrase(phrase): # <<<<<<<<<<<<<<
+ * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase)
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec__phrase(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_phrase) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *__pyx_cur_scope;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("_phrase", 0);
+ __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *)__pyx_ptype_5_cdec___pyx_scope_struct_2__phrase->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_2__phrase, __pyx_empty_tuple, NULL);
+ if (unlikely(!__pyx_cur_scope)) {
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ }
+ __Pyx_GOTREF(__pyx_cur_scope);
+ __pyx_cur_scope->__pyx_v_phrase = __pyx_v_phrase;
+ __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
+ *
+ * def _phrase(phrase):
+ * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) # <<<<<<<<<<<<<<
+ *
+ * cdef class NT:
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_7), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_2 = __pyx_pf_5_cdec_7_phrase_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
+ __Pyx_GIVEREF(__pyx_t_2);
+ __pyx_t_2 = 0;
+ __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __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_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("_cdec._phrase", __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;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ char *__pyx_v_cat;
+ unsigned int __pyx_v_ref;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+ {
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__cat,&__pyx_n_s__ref,0};
+ PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
+ case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
@@ -1227,115 +4875,360 @@ static int __pyx_pw_5_cdec_7Decoder_1__cinit__(PyObject *__pyx_v_self, PyObject
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__config);
- if (likely(values[0])) kw_args--;
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cat)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
+ case 1:
+ if (kw_args > 0) {
+ PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ref);
+ if (value) { values[1] = value; kw_args--; }
+ }
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
- } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
- goto __pyx_L5_argtuple_error;
} else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ switch (PyTuple_GET_SIZE(__pyx_args)) {
+ case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ break;
+ 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;}
+ 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 {
+ __pyx_v_ref = ((unsigned int)0);
}
- __pyx_v_config = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_config) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
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[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
- __Pyx_AddTraceback("_cdec.Decoder.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.NT.__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);
+ __pyx_r = __pyx_pf_5_cdec_2NT___init__(((struct __pyx_obj_5_cdec_NT *)__pyx_v_self), __pyx_v_cat, __pyx_v_ref);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "_cdec.pyx":42
- * cdef public Weights weights
- *
- * def __cinit__(self, char* config): # <<<<<<<<<<<<<<
- * decoder.register_feature_functions()
- * cdef istringstream* config_stream = new istringstream(config)
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":11
+ * cdef public bytes cat
+ * cdef public unsigned ref
+ * def __init__(self, char* cat, unsigned ref=0): # <<<<<<<<<<<<<<
+ * self.cat = cat
+ * self.ref = ref
*/
-static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, char *__pyx_v_config) {
- std::istringstream *__pyx_v_config_stream;
+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) {
int __pyx_r;
__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("__cinit__", 0);
+ __Pyx_RefNannySetupContext("__init__", 0);
- /* "_cdec.pyx":43
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":12
+ * cdef public unsigned ref
+ * def __init__(self, char* cat, unsigned ref=0):
+ * self.cat = cat # <<<<<<<<<<<<<<
+ * self.ref = ref
*
- * def __cinit__(self, char* config):
- * decoder.register_feature_functions() # <<<<<<<<<<<<<<
- * cdef istringstream* config_stream = new istringstream(config)
- * self.dec = new decoder.Decoder(config_stream)
*/
- register_feature_functions();
+ __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_GOTREF(__pyx_v_self->cat);
+ __Pyx_DECREF(((PyObject *)__pyx_v_self->cat));
+ __pyx_v_self->cat = __pyx_t_1;
+ __pyx_t_1 = 0;
- /* "_cdec.pyx":44
- * def __cinit__(self, char* config):
- * decoder.register_feature_functions()
- * cdef istringstream* config_stream = new istringstream(config) # <<<<<<<<<<<<<<
- * self.dec = new decoder.Decoder(config_stream)
- * del config_stream
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":13
+ * def __init__(self, char* cat, unsigned ref=0):
+ * self.cat = cat
+ * self.ref = ref # <<<<<<<<<<<<<<
+ *
+ * def __str__(self):
*/
- __pyx_v_config_stream = new std::istringstream(__pyx_v_config);
+ __pyx_v_self->ref = __pyx_v_ref;
- /* "_cdec.pyx":45
- * decoder.register_feature_functions()
- * cdef istringstream* config_stream = new istringstream(config)
- * self.dec = new decoder.Decoder(config_stream) # <<<<<<<<<<<<<<
- * del config_stream
- * self.weights = Weights(self)
+ __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;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_2NT_3__str__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_2NT_3__str__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_2NT_2__str__(((struct __pyx_obj_5_cdec_NT *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":15
+ * self.ref = ref
+ *
+ * def __str__(self): # <<<<<<<<<<<<<<
+ * if self.ref > 0:
+ * return '[%s,%d]' % (self.cat, self.ref)
*/
- __pyx_v_self->dec = new Decoder(__pyx_v_config_stream);
- /* "_cdec.pyx":46
- * cdef istringstream* config_stream = new istringstream(config)
- * self.dec = new decoder.Decoder(config_stream)
- * del config_stream # <<<<<<<<<<<<<<
- * self.weights = Weights(self)
+static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ int __pyx_t_1;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__str__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":16
*
+ * def __str__(self):
+ * if self.ref > 0: # <<<<<<<<<<<<<<
+ * return '[%s,%d]' % (self.cat, self.ref)
+ * return '[%s]' % self.cat
*/
- delete __pyx_v_config_stream;
+ __pyx_t_1 = (__pyx_v_self->ref > 0);
+ if (__pyx_t_1) {
- /* "_cdec.pyx":47
- * self.dec = new decoder.Decoder(config_stream)
- * del config_stream
- * self.weights = Weights(self) # <<<<<<<<<<<<<<
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":17
+ * def __str__(self):
+ * if self.ref > 0:
+ * return '[%s,%d]' % (self.cat, self.ref) # <<<<<<<<<<<<<<
+ * return '[%s]' % self.cat
*
- * def __dealloc__(self):
*/
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __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_Weights)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __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_GIVEREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_v_self->weights);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->weights));
- __pyx_v_self->weights = ((struct __pyx_obj_5_cdec_Weights *)__pyx_t_2);
+ __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_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_GOTREF(__pyx_t_3);
+ __Pyx_INCREF(((PyObject *)__pyx_v_self->cat));
+ PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->cat));
+ __Pyx_GIVEREF(((PyObject *)__pyx_v_self->cat));
+ 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_GOTREF(((PyObject *)__pyx_t_2));
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __pyx_r = ((PyObject *)__pyx_t_2);
+ __pyx_t_2 = 0;
+ goto __pyx_L0;
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":18
+ * if self.ref > 0:
+ * return '[%s,%d]' % (self.cat, self.ref)
+ * return '[%s]' % self.cat # <<<<<<<<<<<<<<
+ *
+ * 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_GOTREF(((PyObject *)__pyx_t_2));
+ __pyx_r = ((PyObject *)__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_2);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("_cdec.NT.__str__", __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_2NT_3cat_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_2NT_3cat_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_2NT_3cat___get__(((struct __pyx_obj_5_cdec_NT *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/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):
+ */
+
+static PyObject *__pyx_pf_5_cdec_2NT_3cat___get__(struct __pyx_obj_5_cdec_NT *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__", 0);
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_self->cat));
+ __pyx_r = ((PyObject *)__pyx_v_self->cat);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_2NT_3cat_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pw_5_cdec_2NT_3cat_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_2NT_3cat_2__set__(((struct __pyx_obj_5_cdec_NT *)__pyx_v_self), ((PyObject *)__pyx_v_value));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static int __pyx_pf_5_cdec_2NT_3cat_2__set__(struct __pyx_obj_5_cdec_NT *__pyx_v_self, PyObject *__pyx_v_value) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__set__", 0);
+ if (!(likely(PyBytes_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_INCREF(__pyx_v_value);
+ __Pyx_GIVEREF(__pyx_v_value);
+ __Pyx_GOTREF(__pyx_v_self->cat);
+ __Pyx_DECREF(((PyObject *)__pyx_v_self->cat));
+ __pyx_v_self->cat = ((PyObject*)__pyx_v_value);
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.NT.cat.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_2NT_3cat_5__del__(PyObject *__pyx_v_self); /*proto*/
+static int __pyx_pw_5_cdec_2NT_3cat_5__del__(PyObject *__pyx_v_self) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_2NT_3cat_4__del__(((struct __pyx_obj_5_cdec_NT *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static int __pyx_pf_5_cdec_2NT_3cat_4__del__(struct __pyx_obj_5_cdec_NT *__pyx_v_self) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__del__", 0);
+ __Pyx_INCREF(Py_None);
+ __Pyx_GIVEREF(Py_None);
+ __Pyx_GOTREF(__pyx_v_self->cat);
+ __Pyx_DECREF(((PyObject *)__pyx_v_self->cat));
+ __pyx_v_self->cat = ((PyObject*)Py_None);
+
+ __pyx_r = 0;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_2NT_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_2NT_3ref_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_2NT_3ref___get__(((struct __pyx_obj_5_cdec_NT *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/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
+ */
+
+static PyObject *__pyx_pf_5_cdec_2NT_3ref___get__(struct __pyx_obj_5_cdec_NT *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__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 = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __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.Decoder.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.NT.ref.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_2NT_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pw_5_cdec_2NT_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_2NT_3ref_2__set__(((struct __pyx_obj_5_cdec_NT *)__pyx_v_self), ((PyObject *)__pyx_v_value));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static int __pyx_pf_5_cdec_2NT_3ref_2__set__(struct __pyx_obj_5_cdec_NT *__pyx_v_self, PyObject *__pyx_v_value) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ unsigned int __pyx_t_1;
+ int __pyx_lineno = 0;
+ 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 = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_self->ref = __pyx_t_1;
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.NT.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
@@ -1343,374 +5236,616 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_
}
/* Python wrapper */
-static void __pyx_pw_5_cdec_7Decoder_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pw_5_cdec_7Decoder_3__dealloc__(PyObject *__pyx_v_self) {
+static int __pyx_pw_5_cdec_5NTRef_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5_cdec_5NTRef_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ unsigned int __pyx_v_ref;
+ int __pyx_r;
__Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
- __pyx_pf_5_cdec_7Decoder_2__dealloc__(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self));
+ __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+ {
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__ref,0};
+ PyObject* values[1] = {0};
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args;
+ const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+ switch (pos_args) {
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ kw_args = PyDict_Size(__pyx_kwds);
+ switch (pos_args) {
+ case 0:
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ref)) != 0)) kw_args--;
+ else goto __pyx_L5_argtuple_error;
+ }
+ if (unlikely(kw_args > 0)) {
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 22; __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;}
+ }
+ 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_L3_error:;
+ __Pyx_AddTraceback("_cdec.NTRef.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
+ return -1;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_5NTRef___init__(((struct __pyx_obj_5_cdec_NTRef *)__pyx_v_self), __pyx_v_ref);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
}
-/* "_cdec.pyx":49
- * self.weights = Weights(self)
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":22
+ * cdef class NTRef:
+ * cdef public unsigned ref
+ * def __init__(self, unsigned ref): # <<<<<<<<<<<<<<
+ * self.ref = ref
*
- * def __dealloc__(self): # <<<<<<<<<<<<<<
- * del self.dec
+ */
+
+static int __pyx_pf_5_cdec_5NTRef___init__(struct __pyx_obj_5_cdec_NTRef *__pyx_v_self, unsigned int __pyx_v_ref) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__init__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":23
+ * cdef public unsigned ref
+ * def __init__(self, unsigned ref):
+ * self.ref = ref # <<<<<<<<<<<<<<
*
+ * def __str__(self):
*/
+ __pyx_v_self->ref = __pyx_v_ref;
-static void __pyx_pf_5_cdec_7Decoder_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Decoder *__pyx_v_self) {
+ __pyx_r = 0;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_5NTRef_3__str__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5NTRef_3__str__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__dealloc__", 0);
+ __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_5NTRef_2__str__(((struct __pyx_obj_5_cdec_NTRef *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
- /* "_cdec.pyx":50
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":25
+ * self.ref = ref
*
- * def __dealloc__(self):
- * del self.dec # <<<<<<<<<<<<<<
+ * def __str__(self): # <<<<<<<<<<<<<<
+ * return '[%d]' % self.ref
*
- * def read_weights(self, cfg):
*/
- delete __pyx_v_self->dec;
+static PyObject *__pyx_pf_5_cdec_5NTRef_2__str__(struct __pyx_obj_5_cdec_NTRef *__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/grammar.pxi":26
+ *
+ * def __str__(self):
+ * return '[%d]' % self.ref # <<<<<<<<<<<<<<
+ *
+ * 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_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_GOTREF(((PyObject *)__pyx_t_2));
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_r = ((PyObject *)__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.NTRef.__str__", __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_7Decoder_5read_weights(PyObject *__pyx_v_self, PyObject *__pyx_v_cfg); /*proto*/
-static PyObject *__pyx_pw_5_cdec_7Decoder_5read_weights(PyObject *__pyx_v_self, PyObject *__pyx_v_cfg) {
+static PyObject *__pyx_pw_5_cdec_5NTRef_3ref_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5NTRef_3ref_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("read_weights (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_7Decoder_4read_weights(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self), ((PyObject *)__pyx_v_cfg));
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_5NTRef_3ref___get__(((struct __pyx_obj_5_cdec_NTRef *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "_cdec.pyx":52
- * del self.dec
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":21
*
- * def read_weights(self, cfg): # <<<<<<<<<<<<<<
- * with open(cfg) as fp:
- * for line in fp:
+ * cdef class NTRef:
+ * cdef public unsigned ref # <<<<<<<<<<<<<<
+ * def __init__(self, unsigned ref):
+ * self.ref = ref
*/
-static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_cfg) {
- PyObject *__pyx_v_fp = NULL;
- PyObject *__pyx_v_line = NULL;
- PyObject *__pyx_v_fname = NULL;
- PyObject *__pyx_v_value = NULL;
+static PyObject *__pyx_pf_5_cdec_5NTRef_3ref___get__(struct __pyx_obj_5_cdec_NTRef *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ 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_GOTREF(__pyx_t_1);
+ __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_AddTraceback("_cdec.NTRef.ref.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_5NTRef_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pw_5_cdec_5NTRef_3ref_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_5NTRef_3ref_2__set__(((struct __pyx_obj_5_cdec_NTRef *)__pyx_v_self), ((PyObject *)__pyx_v_value));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static int __pyx_pf_5_cdec_5NTRef_3ref_2__set__(struct __pyx_obj_5_cdec_NTRef *__pyx_v_self, PyObject *__pyx_v_value) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ unsigned int __pyx_t_1;
+ int __pyx_lineno = 0;
+ 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_v_self->ref = __pyx_t_1;
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.NTRef.ref.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":28
+ * return '[%d]' % self.ref
+ *
+ * cdef TRule convert_rule(_sa.Rule rule): # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * cdef lhs = _sa.sym_tocat(rule.lhs)
+ */
+
+static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_obj_4cdec_2sa_3_sa_Rule *__pyx_v_rule) {
+ unsigned int __pyx_v_i;
+ PyObject *__pyx_v_lhs = 0;
+ PyObject *__pyx_v_scores = 0;
+ PyObject *__pyx_v_f = NULL;
+ PyObject *__pyx_v_e = NULL;
+ int *__pyx_v_fsyms;
+ int *__pyx_v_esyms;
+ PyObject *__pyx_v_a = 0;
+ PyObject *__pyx_v_point = NULL;
+ struct __pyx_obj_5_cdec_TRule *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_t_2;
+ unsigned int __pyx_t_3;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
+ int __pyx_t_6;
+ int __pyx_t_7;
Py_ssize_t __pyx_t_8;
PyObject *(*__pyx_t_9)(PyObject *);
PyObject *__pyx_t_10 = NULL;
PyObject *__pyx_t_11 = NULL;
- PyObject *(*__pyx_t_12)(PyObject *);
- double __pyx_t_13;
- int __pyx_t_14;
- PyObject *__pyx_t_15 = NULL;
- int __pyx_t_16;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("read_weights", 0);
+ __Pyx_RefNannySetupContext("convert_rule", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":30
+ * cdef TRule convert_rule(_sa.Rule rule):
+ * cdef unsigned i
+ * cdef lhs = _sa.sym_tocat(rule.lhs) # <<<<<<<<<<<<<<
+ * cdef scores = {}
+ * for i in range(rule.n_scores):
+ */
+ __pyx_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tocat(__pyx_v_rule->lhs)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_v_lhs = ((PyObject *)__pyx_t_1);
+ __pyx_t_1 = 0;
- /* "_cdec.pyx":53
- *
- * def read_weights(self, cfg):
- * with open(cfg) as fp: # <<<<<<<<<<<<<<
- * for line in fp:
- * fname, value = line.split()
+ /* "/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]
*/
- /*with:*/ {
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_cfg);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_cfg);
- __Pyx_GIVEREF(__pyx_v_cfg);
- __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 = 53; __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 = 53; __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 = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_v_scores = ((PyObject *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":32
+ * cdef lhs = _sa.sym_tocat(rule.lhs)
+ * cdef scores = {}
+ * for i in range(rule.n_scores): # <<<<<<<<<<<<<<
+ * scores['PhraseModel_'+str(i)] = rule.cscores[i]
+ * f, e = [], []
+ */
+ __pyx_t_2 = __pyx_v_rule->n_scores;
+ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
+ __pyx_v_i = __pyx_t_3;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":33
+ * cdef scores = {}
+ * for i in range(rule.n_scores):
+ * scores['PhraseModel_'+str(i)] = rule.cscores[i] # <<<<<<<<<<<<<<
+ * f, e = [], []
+ * cdef int* fsyms = rule.f.syms
+ */
+ __pyx_t_1 = PyFloat_FromDouble((__pyx_v_rule->cscores[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __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_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- /*try:*/ {
- {
- __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_7);
- /*try:*/ {
- __Pyx_INCREF(__pyx_t_4);
- __pyx_v_fp = __pyx_t_4;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ }
- /* "_cdec.pyx":54
- * def read_weights(self, cfg):
- * with open(cfg) as fp:
- * for line in fp: # <<<<<<<<<<<<<<
- * fname, value = line.split()
- * self.weights[fname.strip()] = float(value)
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":34
+ * for i in range(rule.n_scores):
+ * scores['PhraseModel_'+str(i)] = rule.cscores[i]
+ * f, e = [], [] # <<<<<<<<<<<<<<
+ * cdef int* fsyms = rule.f.syms
+ * for i in range(rule.f.n):
*/
- if (PyList_CheckExact(__pyx_v_fp) || PyTuple_CheckExact(__pyx_v_fp)) {
- __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 = 54; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext;
- }
- for (;;) {
- if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_4)) {
- if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break;
- __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++;
- } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_4)) {
- if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
- __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++;
- } 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 = 54; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_2);
- }
- __Pyx_XDECREF(__pyx_v_line);
- __pyx_v_line = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "_cdec.pyx":55
- * with open(cfg) as fp:
- * for line in fp:
- * fname, value = line.split() # <<<<<<<<<<<<<<
- * self.weights[fname.strip()] = float(value)
- *
+ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_v_f = __pyx_t_1;
+ __pyx_t_1 = 0;
+ __pyx_v_e = __pyx_t_5;
+ __pyx_t_5 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":35
+ * scores['PhraseModel_'+str(i)] = rule.cscores[i]
+ * f, e = [], []
+ * cdef int* fsyms = rule.f.syms # <<<<<<<<<<<<<<
+ * for i in range(rule.f.n):
+ * if _sa.sym_isvar(fsyms[i]):
*/
- __pyx_t_2 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__split); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __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 = 55; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
- PyObject* sequence = __pyx_t_1;
- if (likely(PyTuple_CheckExact(sequence))) {
- if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
- if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
- else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- }
- __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1);
- } else {
- if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
- if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
- else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- }
- __pyx_t_2 = PyList_GET_ITEM(sequence, 0);
- __pyx_t_10 = PyList_GET_ITEM(sequence, 1);
- }
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_10);
- __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[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L7_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;
- index = 0; __pyx_t_2 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_2)) goto __pyx_L18_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_2);
- index = 1; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L18_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_10);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- goto __pyx_L19_unpacking_done;
- __pyx_L18_unpacking_failed:;
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
- if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- __pyx_L19_unpacking_done:;
- }
- __Pyx_XDECREF(__pyx_v_fname);
- __pyx_v_fname = __pyx_t_2;
- __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_v_value);
- __pyx_v_value = __pyx_t_10;
- __pyx_t_10 = 0;
+ __pyx_v_fsyms = __pyx_v_rule->f->syms;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":36
+ * f, e = [], []
+ * cdef int* fsyms = rule.f.syms
+ * for i in range(rule.f.n): # <<<<<<<<<<<<<<
+ * if _sa.sym_isvar(fsyms[i]):
+ * f.append(NT(_sa.sym_tocat(fsyms[i])))
+ */
+ __pyx_t_2 = __pyx_v_rule->f->n;
+ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
+ __pyx_v_i = __pyx_t_3;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":37
+ * cdef int* fsyms = rule.f.syms
+ * for i in range(rule.f.n):
+ * if _sa.sym_isvar(fsyms[i]): # <<<<<<<<<<<<<<
+ * f.append(NT(_sa.sym_tocat(fsyms[i])))
+ * else:
+ */
+ __pyx_t_6 = __pyx_f_4cdec_2sa_3_sa_sym_isvar((__pyx_v_fsyms[__pyx_v_i]));
+ if (__pyx_t_6) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":38
+ * for i in range(rule.f.n):
+ * if _sa.sym_isvar(fsyms[i]):
+ * f.append(NT(_sa.sym_tocat(fsyms[i]))) # <<<<<<<<<<<<<<
+ * else:
+ * f.append(_sa.sym_tostring(fsyms[i]))
+ */
+ __pyx_t_5 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tocat((__pyx_v_fsyms[__pyx_v_i]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_5));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
+ __pyx_t_5 = 0;
+ __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+ __pyx_t_7 = PyList_Append(__pyx_v_f, __pyx_t_5); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ goto __pyx_L7;
+ }
+ /*else*/ {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":40
+ * f.append(NT(_sa.sym_tocat(fsyms[i])))
+ * else:
+ * f.append(_sa.sym_tostring(fsyms[i])) # <<<<<<<<<<<<<<
+ * cdef int* esyms = rule.e.syms
+ * for i in range(rule.e.n):
+ */
+ __pyx_t_5 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tostring((__pyx_v_fsyms[__pyx_v_i]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+ __pyx_t_7 = PyList_Append(__pyx_v_f, ((PyObject *)__pyx_t_5)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ }
+ __pyx_L7:;
+ }
- /* "_cdec.pyx":56
- * for line in fp:
- * fname, value = line.split()
- * self.weights[fname.strip()] = float(value) # <<<<<<<<<<<<<<
- *
- * # TODO: list, lattice translation
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":41
+ * else:
+ * f.append(_sa.sym_tostring(fsyms[i]))
+ * cdef int* esyms = rule.e.syms # <<<<<<<<<<<<<<
+ * for i in range(rule.e.n):
+ * if _sa.sym_isvar(esyms[i]):
*/
- __pyx_t_13 = __Pyx_PyObject_AsDouble(__pyx_v_value); if (unlikely(__pyx_t_13 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- __pyx_t_1 = PyFloat_FromDouble(__pyx_t_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_10 = PyObject_GetAttr(__pyx_v_fname, __pyx_n_s__strip); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- __Pyx_GOTREF(__pyx_t_10);
- __pyx_t_2 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- if (PyObject_SetItem(((PyObject *)__pyx_v_self->weights), __pyx_t_2, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- goto __pyx_L14_try_end;
- __pyx_L7_error:;
- __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __pyx_v_esyms = __pyx_v_rule->e->syms;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":42
+ * f.append(_sa.sym_tostring(fsyms[i]))
+ * cdef int* esyms = rule.e.syms
+ * for i in range(rule.e.n): # <<<<<<<<<<<<<<
+ * if _sa.sym_isvar(esyms[i]):
+ * e.append(NTRef(_sa.sym_getindex(esyms[i])))
+ */
+ __pyx_t_2 = __pyx_v_rule->e->n;
+ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
+ __pyx_v_i = __pyx_t_3;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":43
+ * cdef int* esyms = rule.e.syms
+ * for i in range(rule.e.n):
+ * if _sa.sym_isvar(esyms[i]): # <<<<<<<<<<<<<<
+ * e.append(NTRef(_sa.sym_getindex(esyms[i])))
+ * else:
+ */
+ __pyx_t_6 = __pyx_f_4cdec_2sa_3_sa_sym_isvar((__pyx_v_esyms[__pyx_v_i]));
+ if (__pyx_t_6) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":44
+ * for i in range(rule.e.n):
+ * if _sa.sym_isvar(esyms[i]):
+ * e.append(NTRef(_sa.sym_getindex(esyms[i]))) # <<<<<<<<<<<<<<
+ * else:
+ * e.append(_sa.sym_tostring(esyms[i]))
+ */
+ __pyx_t_5 = PyInt_FromLong(__pyx_f_4cdec_2sa_3_sa_sym_getindex((__pyx_v_esyms[__pyx_v_i]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
+ __Pyx_GIVEREF(__pyx_t_5);
+ __pyx_t_5 = 0;
+ __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+ __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_t_5); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ goto __pyx_L10;
+ }
+ /*else*/ {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":46
+ * e.append(NTRef(_sa.sym_getindex(esyms[i])))
+ * else:
+ * e.append(_sa.sym_tostring(esyms[i])) # <<<<<<<<<<<<<<
+ * cdef a = [(point/65536, point%65536) for point in rule.word_alignments]
+ * return TRule(lhs, f, e, scores, a)
+ */
+ __pyx_t_5 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tostring((__pyx_v_esyms[__pyx_v_i]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+ __pyx_t_7 = PyList_Append(__pyx_v_e, ((PyObject *)__pyx_t_5)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ }
+ __pyx_L10:;
+ }
- /* "_cdec.pyx":53
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":47
+ * else:
+ * e.append(_sa.sym_tostring(esyms[i]))
+ * cdef a = [(point/65536, point%65536) for point in rule.word_alignments] # <<<<<<<<<<<<<<
+ * return TRule(lhs, f, e, scores, a)
*
- * def read_weights(self, cfg):
- * with open(cfg) as fp: # <<<<<<<<<<<<<<
- * for line in fp:
- * fname, value = line.split()
*/
- /*except:*/ {
- __Pyx_AddTraceback("_cdec.Decoder.read_weights", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_INCREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __pyx_t_15 = PyObject_Call(__pyx_t_3, __pyx_t_10, NULL);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
- __Pyx_GOTREF(__pyx_t_15);
- __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_15);
- __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
- if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
- __pyx_t_16 = (!__pyx_t_14);
- if (__pyx_t_16) {
- __Pyx_GIVEREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_ErrRestore(__pyx_t_4, __pyx_t_1, __pyx_t_2);
- __pyx_t_4 = 0; __pyx_t_1 = 0; __pyx_t_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
- goto __pyx_L22;
- }
- __pyx_L22:;
- __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- goto __pyx_L8_exception_handled;
+ __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;}
}
- __pyx_L9_except_error:;
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
- goto __pyx_L1_error;
- __pyx_L8_exception_handled:;
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
- __pyx_L14_try_end:;
- }
- }
- /*finally:*/ {
- if (__pyx_t_3) {
- __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_1, NULL);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __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 = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ break;
}
+ __Pyx_GOTREF(__pyx_t_4);
}
- goto __pyx_L23;
- __pyx_L3_error:;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- goto __pyx_L1_error;
- __pyx_L23:;
+ __Pyx_XDECREF(__pyx_v_point);
+ __pyx_v_point = __pyx_t_4;
+ __pyx_t_4 = 0;
+ __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_v_point, __pyx_int_65536); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_t_10 = PyNumber_Remainder(__pyx_v_point, __pyx_int_65536); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_10);
+ __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_11);
+ PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4);
+ __Pyx_GIVEREF(__pyx_t_4);
+ PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10);
+ __Pyx_GIVEREF(__pyx_t_10);
+ __pyx_t_4 = 0;
+ __pyx_t_10 = 0;
+ if (unlikely(__Pyx_PyList_Append(__pyx_t_5, (PyObject*)__pyx_t_11))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
}
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_INCREF(((PyObject *)__pyx_t_5));
+ __pyx_v_a = ((PyObject *)__pyx_t_5);
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":48
+ * e.append(_sa.sym_tostring(esyms[i]))
+ * cdef a = [(point/65536, point%65536) for point in rule.word_alignments]
+ * return TRule(lhs, f, e, scores, a) # <<<<<<<<<<<<<<
+ *
+ * cdef class TRule:
+ */
+ __Pyx_XDECREF(((PyObject *)__pyx_r));
+ __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_INCREF(__pyx_v_lhs);
+ PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_lhs);
+ __Pyx_GIVEREF(__pyx_v_lhs);
+ __Pyx_INCREF(((PyObject *)__pyx_v_f));
+ PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_f));
+ __Pyx_GIVEREF(((PyObject *)__pyx_v_f));
+ __Pyx_INCREF(((PyObject *)__pyx_v_e));
+ PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)__pyx_v_e));
+ __Pyx_GIVEREF(((PyObject *)__pyx_v_e));
+ __Pyx_INCREF(__pyx_v_scores);
+ PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_scores);
+ __Pyx_GIVEREF(__pyx_v_scores);
+ __Pyx_INCREF(__pyx_v_a);
+ PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_v_a);
+ __Pyx_GIVEREF(__pyx_v_a);
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TRule)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ __pyx_r = ((struct __pyx_obj_5_cdec_TRule *)__pyx_t_1);
+ __pyx_t_1 = 0;
+ goto __pyx_L0;
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ __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_2);
__Pyx_XDECREF(__pyx_t_4);
+ __Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_10);
__Pyx_XDECREF(__pyx_t_11);
- __Pyx_AddTraceback("_cdec.Decoder.read_weights", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
+ __Pyx_AddTraceback("_cdec.convert_rule", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = 0;
__pyx_L0:;
- __Pyx_XDECREF(__pyx_v_fp);
- __Pyx_XDECREF(__pyx_v_line);
- __Pyx_XDECREF(__pyx_v_fname);
- __Pyx_XDECREF(__pyx_v_value);
- __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_XDECREF(__pyx_v_lhs);
+ __Pyx_XDECREF(__pyx_v_scores);
+ __Pyx_XDECREF(__pyx_v_f);
+ __Pyx_XDECREF(__pyx_v_e);
+ __Pyx_XDECREF(__pyx_v_a);
+ __Pyx_XDECREF(__pyx_v_point);
+ __Pyx_XGIVEREF((PyObject *)__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_sentence = 0;
- PyObject *__pyx_v_grammar = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__sentence,&__pyx_n_s__grammar,0};
- PyObject *__pyx_r = 0;
+static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ PyObject *__pyx_v_lhs = 0;
+ PyObject *__pyx_v_f = 0;
+ PyObject *__pyx_v_e = 0;
+ PyObject *__pyx_v_scores = 0;
+ PyObject *__pyx_v_a = 0;
+ int __pyx_r;
__Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("translate (wrapper)", 0);
+ __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
{
- PyObject* values[2] = {0,0};
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__lhs,&__pyx_n_s__f,&__pyx_n_s__e,&__pyx_n_s__scores,&__pyx_n_s__a,0};
+ PyObject* values[5] = {0,0,0,0,0};
- /* "_cdec.pyx":59
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":53
+ * cdef shared_ptr[grammar.TRule]* rule
*
- * # TODO: list, lattice translation
- * def translate(self, unicode sentence, grammar=None): # <<<<<<<<<<<<<<
- * if grammar:
- * self.dec.SetSentenceGrammarFromString(string(<char *> grammar))
+ * def __init__(self, lhs, f, e, scores, a=None): # <<<<<<<<<<<<<<
+ * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule())
+ * self.lhs = lhs
*/
- values[1] = ((PyObject *)Py_None);
+ values[4] = ((PyObject *)Py_None);
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
+ case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+ case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+ case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
@@ -1719,231 +5854,1554 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyO
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sentence);
- if (likely(values[0])) kw_args--;
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lhs)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
+ if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__f)) != 0)) kw_args--;
+ else {
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ case 2:
+ if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__e)) != 0)) kw_args--;
+ else {
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ case 3:
+ if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scores)) != 0)) kw_args--;
+ else {
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ case 4:
if (kw_args > 0) {
- PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grammar);
- if (value) { values[1] = value; kw_args--; }
+ PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__a);
+ if (value) { values[4] = value; kw_args--; }
}
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "translate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __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 = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+ case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+ values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+ values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
- __pyx_v_sentence = ((PyObject*)values[0]);
- __pyx_v_grammar = values[1];
+ __pyx_v_lhs = values[0];
+ __pyx_v_f = values[1];
+ __pyx_v_e = values[2];
+ __pyx_v_scores = values[3];
+ __pyx_v_a = values[4];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("translate", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __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 = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
- __Pyx_AddTraceback("_cdec.Decoder.translate", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.TRule.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
- return NULL;
+ return -1;
__pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentence), (&PyUnicode_Type), 1, "sentence", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_7Decoder_6translate(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self), __pyx_v_sentence, __pyx_v_grammar);
+ __pyx_r = __pyx_pf_5_cdec_5TRule___init__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self), __pyx_v_lhs, __pyx_v_f, __pyx_v_e, __pyx_v_scores, __pyx_v_a);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static int __pyx_pf_5_cdec_5TRule___init__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_f, PyObject *__pyx_v_e, PyObject *__pyx_v_scores, PyObject *__pyx_v_a) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ TRule *__pyx_t_1;
+ int __pyx_t_2;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__init__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":54
+ *
+ * def __init__(self, lhs, f, e, scores, a=None):
+ * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule()) # <<<<<<<<<<<<<<
+ * self.lhs = lhs
+ * self.e = e
+ */
+ try {__pyx_t_1 = new TRule();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}}
+ __pyx_v_self->rule = new boost::shared_ptr<TRule>(__pyx_t_1);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":55
+ * def __init__(self, lhs, f, e, scores, a=None):
+ * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule())
+ * self.lhs = lhs # <<<<<<<<<<<<<<
+ * self.e = e
+ * self.f = f
+ */
+ if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__lhs, __pyx_v_lhs) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":56
+ * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule())
+ * self.lhs = lhs
+ * self.e = e # <<<<<<<<<<<<<<
+ * self.f = f
+ * self.scores = scores
+ */
+ if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__e, __pyx_v_e) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":57
+ * self.lhs = lhs
+ * self.e = e
+ * self.f = f # <<<<<<<<<<<<<<
+ * self.scores = scores
+ * if a:
+ */
+ if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__f, __pyx_v_f) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":58
+ * self.e = e
+ * self.f = f
+ * self.scores = scores # <<<<<<<<<<<<<<
+ * if a:
+ * self.a = a
+ */
+ if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__scores, __pyx_v_scores) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":59
+ * self.f = f
+ * self.scores = scores
+ * if a: # <<<<<<<<<<<<<<
+ * self.a = a
+ * self.rule.get().ComputeArity()
+ */
+ __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_a); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__pyx_t_2) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":60
+ * self.scores = scores
+ * if a:
+ * self.a = a # <<<<<<<<<<<<<<
+ * self.rule.get().ComputeArity()
+ *
+ */
+ if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__a, __pyx_v_a) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":61
+ * if a:
+ * self.a = a
+ * self.rule.get().ComputeArity() # <<<<<<<<<<<<<<
+ *
+ * def __dealloc__(self):
+ */
+ __pyx_v_self->rule->get()->ComputeArity();
+
+ __pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.TRule.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static void __pyx_pw_5_cdec_5TRule_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_5_cdec_5TRule_3__dealloc__(PyObject *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+ __pyx_pf_5_cdec_5TRule_2__dealloc__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":63
+ * self.rule.get().ComputeArity()
+ *
+ * def __dealloc__(self): # <<<<<<<<<<<<<<
+ * del self.rule
+ *
+ */
+
+static void __pyx_pf_5_cdec_5TRule_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":64
+ *
+ * def __dealloc__(self):
+ * del self.rule # <<<<<<<<<<<<<<
+ *
+ * property arity:
+ */
+ delete __pyx_v_self->rule;
+
+ __Pyx_RefNannyFinishContext();
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_5TRule_5arity_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5TRule_5arity_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_5TRule_5arity___get__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":67
+ *
+ * property arity:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * return self.rule.get().arity_
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_5TRule_5arity___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ 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":68
+ * property arity:
+ * def __get__(self):
+ * return self.rule.get().arity_ # <<<<<<<<<<<<<<
+ *
+ * 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_GOTREF(__pyx_t_1);
+ __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_AddTraceback("_cdec.TRule.arity.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_sentence, PyObject *__pyx_v_grammar) {
- PyObject *__pyx_v_inp = NULL;
- BasicObserver __pyx_v_observer;
- struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_hg = 0;
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_5TRule_1f_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5TRule_1f_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_5TRule_1f___get__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":71
+ *
+ * property f:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef vector[WordID]* f_ = &self.rule.get().f_
+ * cdef WordID w
+ */
+
+static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
+ std::vector<WordID> *__pyx_v_f_;
+ WordID __pyx_v_w;
+ PyObject *__pyx_v_f = 0;
+ unsigned int __pyx_v_i;
+ int __pyx_v_idx;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
- int __pyx_t_1;
- char *__pyx_t_2;
+ 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_6 = 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":72
+ * property f:
+ * def __get__(self):
+ * cdef vector[WordID]* f_ = &self.rule.get().f_ # <<<<<<<<<<<<<<
+ * cdef WordID w
+ * cdef f = []
+ */
+ __pyx_v_f_ = (&__pyx_v_self->rule->get()->f_);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":74
+ * cdef vector[WordID]* f_ = &self.rule.get().f_
+ * cdef WordID w
+ * cdef f = [] # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * cdef int idx = 0
+ */
+ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_v_f = ((PyObject *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":76
+ * cdef f = []
+ * cdef unsigned i
+ * cdef int idx = 0 # <<<<<<<<<<<<<<
+ * for i in range(f_.size()):
+ * w = f_[0][i]
+ */
+ __pyx_v_idx = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":77
+ * cdef unsigned i
+ * cdef int idx = 0
+ * for i in range(f_.size()): # <<<<<<<<<<<<<<
+ * w = f_[0][i]
+ * if w < 0:
+ */
+ __pyx_t_2 = __pyx_v_f_->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/grammar.pxi":78
+ * cdef int idx = 0
+ * for i in range(f_.size()):
+ * w = f_[0][i] # <<<<<<<<<<<<<<
+ * if w < 0:
+ * idx += 1
+ */
+ __pyx_v_w = ((__pyx_v_f_[0])[__pyx_v_i]);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":79
+ * for i in range(f_.size()):
+ * w = f_[0][i]
+ * if w < 0: # <<<<<<<<<<<<<<
+ * idx += 1
+ * f.append(NT(TDConvert(-w), idx))
+ */
+ __pyx_t_4 = (__pyx_v_w < 0);
+ if (__pyx_t_4) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":80
+ * w = f_[0][i]
+ * if w < 0:
+ * idx += 1 # <<<<<<<<<<<<<<
+ * f.append(NT(TDConvert(-w), idx))
+ * else:
+ */
+ __pyx_v_idx = (__pyx_v_idx + 1);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":81
+ * if w < 0:
+ * idx += 1
+ * f.append(NT(TDConvert(-w), idx)) # <<<<<<<<<<<<<<
+ * else:
+ * f.append(unicode(TDConvert(w), encoding='utf8'))
+ */
+ __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_w))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_t_5 = PyInt_FromLong(__pyx_v_idx); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_1));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+ PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
+ __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_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_GOTREF(__pyx_t_6);
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ goto __pyx_L5;
+ }
+ /*else*/ {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":83
+ * f.append(NT(TDConvert(-w), idx))
+ * else:
+ * f.append(unicode(TDConvert(w), encoding='utf8')) # <<<<<<<<<<<<<<
+ * return f
+ *
+ */
+ __pyx_t_6 = PyBytes_FromString(TD::Convert(__pyx_v_w)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_6));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
+ __pyx_t_6 = 0;
+ __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+ if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+ __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_f, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ }
+ __pyx_L5:;
+ }
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":84
+ * else:
+ * f.append(unicode(TDConvert(w), encoding='utf8'))
+ * return f # <<<<<<<<<<<<<<
+ *
+ * def __set__(self, f):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(__pyx_v_f);
+ __pyx_r = __pyx_v_f;
+ 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_5);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_AddTraceback("_cdec.TRule.f.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_f);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_5TRule_1f_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
+static int __pyx_pw_5_cdec_5TRule_1f_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_5TRule_1f_2__set__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self), ((PyObject *)__pyx_v_f));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":86
+ * return f
+ *
+ * def __set__(self, f): # <<<<<<<<<<<<<<
+ * cdef vector[WordID]* f_ = &self.rule.get().f_
+ * f_.resize(len(f))
+ */
+
+static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_f) {
+ std::vector<WordID> *__pyx_v_f_;
+ unsigned int __pyx_v_i;
+ CYTHON_UNUSED int __pyx_v_idx;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ Py_ssize_t __pyx_t_1;
+ unsigned int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
+ int __pyx_t_5;
+ char *__pyx_t_6;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("translate", 0);
+ __Pyx_RefNannySetupContext("__set__", 0);
- /* "_cdec.pyx":60
- * # TODO: list, lattice translation
- * def translate(self, unicode sentence, grammar=None):
- * if grammar: # <<<<<<<<<<<<<<
- * self.dec.SetSentenceGrammarFromString(string(<char *> grammar))
- * inp = sentence.strip().encode('utf8')
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":87
+ *
+ * def __set__(self, f):
+ * cdef vector[WordID]* f_ = &self.rule.get().f_ # <<<<<<<<<<<<<<
+ * f_.resize(len(f))
+ * cdef unsigned i
*/
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_grammar); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__pyx_t_1) {
+ __pyx_v_f_ = (&__pyx_v_self->rule->get()->f_);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":88
+ * def __set__(self, f):
+ * cdef vector[WordID]* f_ = &self.rule.get().f_
+ * f_.resize(len(f)) # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * cdef int idx = 0
+ */
+ __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_f_->resize(__pyx_t_1);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":90
+ * f_.resize(len(f))
+ * cdef unsigned i
+ * cdef int idx = 0 # <<<<<<<<<<<<<<
+ * for i in range(len(f)):
+ * if isinstance(f[i], NT):
+ */
+ __pyx_v_idx = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":91
+ * cdef unsigned i
+ * cdef int idx = 0
+ * for i in range(len(f)): # <<<<<<<<<<<<<<
+ * if isinstance(f[i], NT):
+ * f_[0][i] = -TDConvert(<char *>f[i].cat)
+ */
+ __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
+ __pyx_v_i = __pyx_t_2;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":92
+ * cdef int idx = 0
+ * for i in range(len(f)):
+ * if isinstance(f[i], NT): # <<<<<<<<<<<<<<
+ * f_[0][i] = -TDConvert(<char *>f[i].cat)
+ * else:
+ */
+ __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_4 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT));
+ __Pyx_INCREF(__pyx_t_4);
+ __pyx_t_5 = __Pyx_TypeCheck(__pyx_t_3, __pyx_t_4);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ if (__pyx_t_5) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":93
+ * for i in range(len(f)):
+ * if isinstance(f[i], NT):
+ * f_[0][i] = -TDConvert(<char *>f[i].cat) # <<<<<<<<<<<<<<
+ * else:
+ * f_[0][i] = TDConvert(<char *>as_str(f[i]))
+ */
+ __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__cat); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __pyx_t_6 = PyBytes_AsString(__pyx_t_3); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ ((__pyx_v_f_[0])[__pyx_v_i]) = (-TD::Convert(((char *)__pyx_t_6)));
+ goto __pyx_L5;
+ }
+ /*else*/ {
- /* "_cdec.pyx":61
- * def translate(self, unicode sentence, grammar=None):
- * if grammar:
- * self.dec.SetSentenceGrammarFromString(string(<char *> grammar)) # <<<<<<<<<<<<<<
- * inp = sentence.strip().encode('utf8')
- * cdef decoder.BasicObserver observer = decoder.BasicObserver()
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":95
+ * f_[0][i] = -TDConvert(<char *>f[i].cat)
+ * else:
+ * f_[0][i] = TDConvert(<char *>as_str(f[i])) # <<<<<<<<<<<<<<
+ *
+ * property e:
*/
- __pyx_t_2 = PyBytes_AsString(__pyx_v_grammar); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_v_self->dec->SetSentenceGrammarFromString(std::string(((char *)__pyx_t_2)));
- goto __pyx_L3;
+ __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ ((__pyx_v_f_[0])[__pyx_v_i]) = TD::Convert(((char *)__pyx_f_5_cdec_as_str(__pyx_t_3, NULL)));
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ }
+ __pyx_L5:;
}
- __pyx_L3:;
- /* "_cdec.pyx":62
- * if grammar:
- * self.dec.SetSentenceGrammarFromString(string(<char *> grammar))
- * inp = sentence.strip().encode('utf8') # <<<<<<<<<<<<<<
- * cdef decoder.BasicObserver observer = decoder.BasicObserver()
- * self.dec.Decode(string(<char *>inp), &observer)
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_AddTraceback("_cdec.TRule.f.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_5TRule_1e_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5TRule_1e_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_5TRule_1e___get__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":98
+ *
+ * property e:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef vector[WordID]* e_ = &self.rule.get().e_
+ * cdef WordID w
*/
- __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_sentence), __pyx_n_s__strip); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_inp = __pyx_t_4;
- __pyx_t_4 = 0;
- /* "_cdec.pyx":63
- * self.dec.SetSentenceGrammarFromString(string(<char *> grammar))
- * inp = sentence.strip().encode('utf8')
- * cdef decoder.BasicObserver observer = decoder.BasicObserver() # <<<<<<<<<<<<<<
- * self.dec.Decode(string(<char *>inp), &observer)
- * if observer.hypergraph == NULL:
+static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
+ std::vector<WordID> *__pyx_v_e_;
+ WordID __pyx_v_w;
+ PyObject *__pyx_v_e = 0;
+ unsigned int __pyx_v_i;
+ int __pyx_v_idx;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ 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_6 = 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":99
+ * property e:
+ * def __get__(self):
+ * cdef vector[WordID]* e_ = &self.rule.get().e_ # <<<<<<<<<<<<<<
+ * cdef WordID w
+ * cdef e = []
*/
- __pyx_v_observer = BasicObserver();
+ __pyx_v_e_ = (&__pyx_v_self->rule->get()->e_);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":101
+ * cdef vector[WordID]* e_ = &self.rule.get().e_
+ * cdef WordID w
+ * cdef e = [] # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * cdef int idx = 0
+ */
+ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_v_e = ((PyObject *)__pyx_t_1);
+ __pyx_t_1 = 0;
- /* "_cdec.pyx":64
- * inp = sentence.strip().encode('utf8')
- * cdef decoder.BasicObserver observer = decoder.BasicObserver()
- * self.dec.Decode(string(<char *>inp), &observer) # <<<<<<<<<<<<<<
- * if observer.hypergraph == NULL:
- * raise ParseFailed()
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":103
+ * cdef e = []
+ * cdef unsigned i
+ * cdef int idx = 0 # <<<<<<<<<<<<<<
+ * for i in range(e_.size()):
+ * w = e_[0][i]
*/
- __pyx_t_2 = PyBytes_AsString(__pyx_v_inp); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_v_self->dec->Decode(std::string(((char *)__pyx_t_2)), (&__pyx_v_observer));
+ __pyx_v_idx = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":104
+ * cdef unsigned i
+ * cdef int idx = 0
+ * for i in range(e_.size()): # <<<<<<<<<<<<<<
+ * w = e_[0][i]
+ * if w < 1:
+ */
+ __pyx_t_2 = __pyx_v_e_->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/grammar.pxi":105
+ * cdef int idx = 0
+ * for i in range(e_.size()):
+ * w = e_[0][i] # <<<<<<<<<<<<<<
+ * if w < 1:
+ * idx += 1
+ */
+ __pyx_v_w = ((__pyx_v_e_[0])[__pyx_v_i]);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":106
+ * for i in range(e_.size()):
+ * w = e_[0][i]
+ * if w < 1: # <<<<<<<<<<<<<<
+ * idx += 1
+ * e.append(NTRef(1-w))
+ */
+ __pyx_t_4 = (__pyx_v_w < 1);
+ if (__pyx_t_4) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":107
+ * w = e_[0][i]
+ * if w < 1:
+ * idx += 1 # <<<<<<<<<<<<<<
+ * e.append(NTRef(1-w))
+ * else:
+ */
+ __pyx_v_idx = (__pyx_v_idx + 1);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":108
+ * if w < 1:
+ * idx += 1
+ * e.append(NTRef(1-w)) # <<<<<<<<<<<<<<
+ * else:
+ * e.append(unicode(TDConvert(w), encoding='utf8'))
+ */
+ __pyx_t_1 = PyInt_FromLong((1 - __pyx_v_w)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
+ __Pyx_GIVEREF(__pyx_t_1);
+ __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_e, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ goto __pyx_L5;
+ }
+ /*else*/ {
- /* "_cdec.pyx":65
- * cdef decoder.BasicObserver observer = decoder.BasicObserver()
- * self.dec.Decode(string(<char *>inp), &observer)
- * if observer.hypergraph == NULL: # <<<<<<<<<<<<<<
- * raise ParseFailed()
- * cdef Hypergraph hg = Hypergraph()
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":110
+ * e.append(NTRef(1-w))
+ * else:
+ * e.append(unicode(TDConvert(w), encoding='utf8')) # <<<<<<<<<<<<<<
+ * return e
+ *
*/
- __pyx_t_1 = (__pyx_v_observer.hypergraph == NULL);
- if (__pyx_t_1) {
+ __pyx_t_5 = PyBytes_FromString(TD::Convert(__pyx_v_w)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_5));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
+ __pyx_t_5 = 0;
+ __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+ if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_e, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ }
+ __pyx_L5:;
+ }
- /* "_cdec.pyx":66
- * self.dec.Decode(string(<char *>inp), &observer)
- * if observer.hypergraph == NULL:
- * raise ParseFailed() # <<<<<<<<<<<<<<
- * cdef Hypergraph hg = Hypergraph()
- * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0])
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":111
+ * else:
+ * e.append(unicode(TDConvert(w), encoding='utf8'))
+ * return e # <<<<<<<<<<<<<<
+ *
+ * def __set__(self, e):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(__pyx_v_e);
+ __pyx_r = __pyx_v_e;
+ 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_5);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_AddTraceback("_cdec.TRule.e.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_e);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_5TRule_1e_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_e); /*proto*/
+static int __pyx_pw_5_cdec_5TRule_1e_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_e) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_5TRule_1e_2__set__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self), ((PyObject *)__pyx_v_e));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":113
+ * return e
+ *
+ * def __set__(self, e): # <<<<<<<<<<<<<<
+ * cdef vector[WordID]* e_ = &self.rule.get().e_
+ * e_.resize(len(e))
+ */
+
+static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_e) {
+ std::vector<WordID> *__pyx_v_e_;
+ unsigned int __pyx_v_i;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ Py_ssize_t __pyx_t_1;
+ unsigned int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ PyObject *__pyx_t_4 = NULL;
+ int __pyx_t_5;
+ WordID __pyx_t_6;
+ 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
+ *
+ * def __set__(self, e):
+ * cdef vector[WordID]* e_ = &self.rule.get().e_ # <<<<<<<<<<<<<<
+ * e_.resize(len(e))
+ * cdef unsigned i
+ */
+ __pyx_v_e_ = (&__pyx_v_self->rule->get()->e_);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":115
+ * def __set__(self, e):
+ * cdef vector[WordID]* e_ = &self.rule.get().e_
+ * e_.resize(len(e)) # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * for i in range(len(e)):
+ */
+ __pyx_t_1 = PyObject_Length(__pyx_v_e); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_e_->resize(__pyx_t_1);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":117
+ * e_.resize(len(e))
+ * cdef unsigned i
+ * for i in range(len(e)): # <<<<<<<<<<<<<<
+ * if isinstance(e[i], NTRef):
+ * e_[0][i] = 1-e[i].ref
+ */
+ __pyx_t_1 = PyObject_Length(__pyx_v_e); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
+ __pyx_v_i = __pyx_t_2;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":118
+ * cdef unsigned i
+ * for i in range(len(e)):
+ * if isinstance(e[i], NTRef): # <<<<<<<<<<<<<<
+ * e_[0][i] = 1-e[i].ref
+ * else:
+ */
+ __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_4 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef));
+ __Pyx_INCREF(__pyx_t_4);
+ __pyx_t_5 = __Pyx_TypeCheck(__pyx_t_3, __pyx_t_4);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ if (__pyx_t_5) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":119
+ * for i in range(len(e)):
+ * if isinstance(e[i], NTRef):
+ * e_[0][i] = 1-e[i].ref # <<<<<<<<<<<<<<
+ * else:
+ * e_[0][i] = TDConvert(<char *>as_str(e[i]))
+ */
+ __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__ref); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __pyx_t_4 = PyNumber_Subtract(__pyx_int_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_t_6 = __Pyx_PyInt_from_py_WordID(__pyx_t_4); if (unlikely((__pyx_t_6 == (WordID)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ ((__pyx_v_e_[0])[__pyx_v_i]) = __pyx_t_6;
+ goto __pyx_L5;
+ }
+ /*else*/ {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":121
+ * e_[0][i] = 1-e[i].ref
+ * else:
+ * e_[0][i] = TDConvert(<char *>as_str(e[i])) # <<<<<<<<<<<<<<
+ *
+ * property a:
+ */
+ __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ ((__pyx_v_e_[0])[__pyx_v_i]) = TD::Convert(((char *)__pyx_f_5_cdec_as_str(__pyx_t_4, NULL)));
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ }
+ __pyx_L5:;
+ }
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_AddTraceback("_cdec.TRule.e.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+static PyObject *__pyx_gb_5_cdec_5TRule_1a_2generator2(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_5TRule_1a_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5TRule_1a_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_5TRule_1a___get__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":124
+ *
+ * property a:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_
*/
- __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__ParseFailed); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+static PyObject *__pyx_pf_5_cdec_5TRule_1a___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *__pyx_cur_scope;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ 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_4___get__ *)__pyx_ptype_5_cdec___pyx_scope_struct_4___get__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_4___get__, __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_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_5TRule_1a_2generator2, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_cur_scope);
+ __Pyx_RefNannyFinishContext();
+ return (PyObject *) gen;
+ }
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.TRule.a.__get__", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_5TRule_1a_2generator2(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+ struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *)__pyx_generator->closure);
+ PyObject *__pyx_r = NULL;
+ size_t __pyx_t_1;
+ unsigned int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ 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_L6_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[2]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":126
+ * def __get__(self):
+ * cdef unsigned i
+ * cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_ # <<<<<<<<<<<<<<
+ * for i in range(a.size()):
+ * yield (a[0][i].s_, a[0][i].t_)
+ */
+ __pyx_cur_scope->__pyx_v_a = (&__pyx_cur_scope->__pyx_v_self->rule->get()->a_);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":127
+ * cdef unsigned i
+ * cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_
+ * for i in range(a.size()): # <<<<<<<<<<<<<<
+ * yield (a[0][i].s_, a[0][i].t_)
+ *
+ */
+ __pyx_t_1 = __pyx_cur_scope->__pyx_v_a->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/grammar.pxi":128
+ * cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_
+ * for i in range(a.size()):
+ * yield (a[0][i].s_, a[0][i].t_) # <<<<<<<<<<<<<<
+ *
+ * def __set__(self, a):
+ */
+ __pyx_t_3 = PyInt_FromLong(((__pyx_cur_scope->__pyx_v_a[0])[__pyx_cur_scope->__pyx_v_i]).s_); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_4 = PyInt_FromLong(((__pyx_cur_scope->__pyx_v_a[0])[__pyx_cur_scope->__pyx_v_i]).t_); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
+ __Pyx_GIVEREF(__pyx_t_3);
+ PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
+ __Pyx_GIVEREF(__pyx_t_4);
+ __pyx_t_3 = 0;
+ __pyx_t_4 = 0;
+ __pyx_r = ((PyObject *)__pyx_t_5);
+ __pyx_t_5 = 0;
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 1;
+ return __pyx_r;
+ __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;}
+ }
+ PyErr_SetNone(PyExc_StopIteration);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_XDECREF(__pyx_t_5);
+ __Pyx_AddTraceback("__get__", __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 int __pyx_pw_5_cdec_5TRule_1a_4__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_a); /*proto*/
+static int __pyx_pw_5_cdec_5TRule_1a_4__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_a) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_5TRule_1a_3__set__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self), ((PyObject *)__pyx_v_a));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":130
+ * yield (a[0][i].s_, a[0][i].t_)
+ *
+ * def __set__(self, a): # <<<<<<<<<<<<<<
+ * cdef vector[grammar.AlignmentPoint]* a_ = &self.rule.get().a_
+ * a_.resize(len(a))
+ */
+
+static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_a) {
+ std::vector<AlignmentPoint> *__pyx_v_a_;
+ unsigned int __pyx_v_i;
+ int __pyx_v_s;
+ int __pyx_v_t;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ Py_ssize_t __pyx_t_1;
+ unsigned int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ PyObject *__pyx_t_4 = NULL;
+ PyObject *__pyx_t_5 = NULL;
+ PyObject *__pyx_t_6 = NULL;
+ PyObject *(*__pyx_t_7)(PyObject *);
+ int __pyx_t_8;
+ int __pyx_t_9;
+ 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":131
+ *
+ * def __set__(self, a):
+ * cdef vector[grammar.AlignmentPoint]* a_ = &self.rule.get().a_ # <<<<<<<<<<<<<<
+ * a_.resize(len(a))
+ * cdef unsigned i
+ */
+ __pyx_v_a_ = (&__pyx_v_self->rule->get()->a_);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":132
+ * def __set__(self, a):
+ * cdef vector[grammar.AlignmentPoint]* a_ = &self.rule.get().a_
+ * a_.resize(len(a)) # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * cdef int s, t
+ */
+ __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_a_->resize(__pyx_t_1);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":135
+ * cdef unsigned i
+ * cdef int s, t
+ * for i in range(len(a)): # <<<<<<<<<<<<<<
+ * s, t = a[i]
+ * a_[0][i] = grammar.AlignmentPoint(s, t)
+ */
+ __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
+ __pyx_v_i = __pyx_t_2;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":136
+ * cdef int s, t
+ * for i in range(len(a)):
+ * s, t = a[i] # <<<<<<<<<<<<<<
+ * a_[0][i] = grammar.AlignmentPoint(s, t)
+ *
+ */
+ __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_a, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
+ if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
+ PyObject* sequence = __pyx_t_3;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 2)) {
+ if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
+ if (likely(PyTuple_CheckExact(sequence))) {
+ __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
+ __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
+ } else {
+ __pyx_t_4 = PyList_GET_ITEM(sequence, 0);
+ __pyx_t_5 = PyList_GET_ITEM(sequence, 1);
+ }
+ __Pyx_INCREF(__pyx_t_4);
+ __Pyx_INCREF(__pyx_t_5);
+ #else
+ __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ } else
+ {
+ 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_GOTREF(__pyx_t_6);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
+ index = 0; __pyx_t_4 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
+ __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;}
+ __pyx_t_7 = NULL;
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ goto __pyx_L6_unpacking_done;
+ __pyx_L5_unpacking_failed:;
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __pyx_t_7 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_L6_unpacking_done:;
+ }
+ __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- goto __pyx_L4;
+ __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __pyx_v_s = __pyx_t_8;
+ __pyx_v_t = __pyx_t_9;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":137
+ * for i in range(len(a)):
+ * s, t = a[i]
+ * a_[0][i] = grammar.AlignmentPoint(s, t) # <<<<<<<<<<<<<<
+ *
+ * property scores:
+ */
+ ((__pyx_v_a_[0])[__pyx_v_i]) = AlignmentPoint(__pyx_v_s, __pyx_v_t);
}
- __pyx_L4:;
- /* "_cdec.pyx":67
- * if observer.hypergraph == NULL:
- * raise ParseFailed()
- * cdef Hypergraph hg = Hypergraph() # <<<<<<<<<<<<<<
- * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0])
- * return hg
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_XDECREF(__pyx_t_5);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_AddTraceback("_cdec.TRule.a.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_5TRule_6scores_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5TRule_6scores_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_5TRule_6scores___get__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":140
+ *
+ * property scores:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef SparseVector scores = SparseVector.__new__(SparseVector)
+ * scores.vector = new FastSparseVector[double](self.rule.get().scores_)
*/
- __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 = 67; __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":68
- * raise ParseFailed()
- * cdef Hypergraph hg = Hypergraph()
- * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0]) # <<<<<<<<<<<<<<
- * return hg
+static PyObject *__pyx_pf_5_cdec_5TRule_6scores___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_scores = 0;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = 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":141
+ * 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_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_scores = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":142
+ * def __get__(self):
+ * cdef SparseVector scores = SparseVector.__new__(SparseVector)
+ * scores.vector = new FastSparseVector[double](self.rule.get().scores_) # <<<<<<<<<<<<<<
+ * return scores
*
*/
- __pyx_v_hg->hg = new Hypergraph((__pyx_v_observer.hypergraph[0]));
+ __pyx_v_scores->vector = new FastSparseVector<double>(__pyx_v_self->rule->get()->scores_);
- /* "_cdec.pyx":69
- * cdef Hypergraph hg = Hypergraph()
- * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0])
- * return hg # <<<<<<<<<<<<<<
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":143
+ * cdef SparseVector scores = SparseVector.__new__(SparseVector)
+ * scores.vector = new FastSparseVector[double](self.rule.get().scores_)
+ * return scores # <<<<<<<<<<<<<<
*
- * cdef class Hypergraph:
+ * def __set__(self, scores):
*/
__Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_hg));
- __pyx_r = ((PyObject *)__pyx_v_hg);
+ __Pyx_INCREF(((PyObject *)__pyx_v_scores));
+ __pyx_r = ((PyObject *)__pyx_v_scores);
goto __pyx_L0;
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("_cdec.Decoder.translate", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.TRule.scores.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
- __Pyx_XDECREF(__pyx_v_inp);
- __Pyx_XDECREF((PyObject *)__pyx_v_hg);
+ __Pyx_XDECREF((PyObject *)__pyx_v_scores);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_7Decoder_7weights_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_7Decoder_7weights_1__get__(PyObject *__pyx_v_self) {
+static int __pyx_pw_5_cdec_5TRule_6scores_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_scores); /*proto*/
+static int __pyx_pw_5_cdec_5TRule_6scores_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_scores) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_5TRule_6scores_2__set__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self), ((PyObject *)__pyx_v_scores));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":145
+ * return scores
+ *
+ * def __set__(self, scores): # <<<<<<<<<<<<<<
+ * cdef FastSparseVector[double]* scores_ = &self.rule.get().scores_
+ * scores_.clear()
+ */
+
+static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_scores) {
+ FastSparseVector<double> *__pyx_v_scores_;
+ int __pyx_v_fid;
+ float __pyx_v_fval;
+ PyObject *__pyx_v_fname = NULL;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ Py_ssize_t __pyx_t_3;
+ PyObject *(*__pyx_t_4)(PyObject *);
+ PyObject *__pyx_t_5 = NULL;
+ PyObject *__pyx_t_6 = NULL;
+ PyObject *__pyx_t_7 = NULL;
+ PyObject *(*__pyx_t_8)(PyObject *);
+ float __pyx_t_9;
+ int __pyx_t_10;
+ 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
+ *
+ * def __set__(self, scores):
+ * cdef FastSparseVector[double]* scores_ = &self.rule.get().scores_ # <<<<<<<<<<<<<<
+ * scores_.clear()
+ * cdef int fid
+ */
+ __pyx_v_scores_ = (&__pyx_v_self->rule->get()->scores_);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":147
+ * def __set__(self, scores):
+ * cdef FastSparseVector[double]* scores_ = &self.rule.get().scores_
+ * scores_.clear() # <<<<<<<<<<<<<<
+ * cdef int fid
+ * cdef float fval
+ */
+ __pyx_v_scores_->clear();
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":150
+ * cdef int fid
+ * cdef float fval
+ * for fname, fval in scores.items(): # <<<<<<<<<<<<<<
+ * fid = FDConvert(<char *>as_str(fname))
+ * if fid < 0: raise KeyError(fname)
+ */
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_scores, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
+ __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
+ __pyx_t_4 = NULL;
+ } else {
+ __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
+ }
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ for (;;) {
+ if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_2 = __pyx_t_4(__pyx_t_1);
+ if (unlikely(!__pyx_t_2)) {
+ if (PyErr_Occurred()) {
+ if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
+ else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_2);
+ }
+ if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
+ PyObject* sequence = __pyx_t_2;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 2)) {
+ if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
+ if (likely(PyTuple_CheckExact(sequence))) {
+ __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
+ __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
+ } else {
+ __pyx_t_5 = PyList_GET_ITEM(sequence, 0);
+ __pyx_t_6 = PyList_GET_ITEM(sequence, 1);
+ }
+ __Pyx_INCREF(__pyx_t_5);
+ __Pyx_INCREF(__pyx_t_6);
+ #else
+ __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ } else
+ {
+ 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_GOTREF(__pyx_t_7);
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
+ index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
+ __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;}
+ __pyx_t_8 = NULL;
+ __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+ goto __pyx_L6_unpacking_done;
+ __pyx_L5_unpacking_failed:;
+ __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+ __pyx_t_8 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_L6_unpacking_done:;
+ }
+ __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __Pyx_XDECREF(__pyx_v_fname);
+ __pyx_v_fname = __pyx_t_5;
+ __pyx_t_5 = 0;
+ __pyx_v_fval = __pyx_t_9;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":151
+ * cdef float fval
+ * for fname, fval in scores.items():
+ * fid = FDConvert(<char *>as_str(fname)) # <<<<<<<<<<<<<<
+ * 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)));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":152
+ * for fname, fval in scores.items():
+ * fid = FDConvert(<char *>as_str(fname))
+ * if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<<
+ * 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_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_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;}
+ goto __pyx_L7;
+ }
+ __pyx_L7:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":153
+ * fid = FDConvert(<char *>as_str(fname))
+ * if fid < 0: raise KeyError(fname)
+ * scores_.set_value(fid, fval) # <<<<<<<<<<<<<<
+ *
+ * property lhs:
+ */
+ __pyx_v_scores_->set_value(__pyx_v_fid, __pyx_v_fval);
+ }
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_2);
+ __Pyx_XDECREF(__pyx_t_5);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_XDECREF(__pyx_t_7);
+ __Pyx_AddTraceback("_cdec.TRule.scores.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_fname);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_5TRule_3lhs_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5TRule_3lhs_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_7Decoder_7weights___get__(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_5TRule_3lhs___get__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "_cdec.pyx":40
- * cdef class Decoder:
- * cdef decoder.Decoder* dec
- * cdef public Weights weights # <<<<<<<<<<<<<<
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":156
+ *
+ * property lhs:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * return NT(TDConvert(-self.rule.get().lhs_))
*
- * def __cinit__(self, char* config):
*/
-static PyObject *__pyx_pf_5_cdec_7Decoder_7weights___get__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_5TRule_3lhs___get__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ 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":157
+ * property lhs:
+ * def __get__(self):
+ * return NT(TDConvert(-self.rule.get().lhs_)) # <<<<<<<<<<<<<<
+ *
+ * def __set__(self, lhs):
+ */
__Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self->weights));
- __pyx_r = ((PyObject *)__pyx_v_self->weights);
+ __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_self->rule->get()->lhs_))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+ __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+ __pyx_r = __pyx_t_1;
+ __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.TRule.lhs.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
@@ -1951,62 +7409,1176 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_7weights___get__(struct __pyx_obj_5_cd
}
/* Python wrapper */
-static int __pyx_pw_5_cdec_7Decoder_7weights_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_pw_5_cdec_7Decoder_7weights_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+static int __pyx_pw_5_cdec_5TRule_3lhs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_lhs); /*proto*/
+static int __pyx_pw_5_cdec_5TRule_3lhs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_lhs) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_7Decoder_7weights_2__set__(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self), ((PyObject *)__pyx_v_value));
+ __pyx_r = __pyx_pf_5_cdec_5TRule_3lhs_2__set__(((struct __pyx_obj_5_cdec_TRule *)__pyx_v_self), ((PyObject *)__pyx_v_lhs));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_value) {
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":159
+ * return NT(TDConvert(-self.rule.get().lhs_))
+ *
+ * def __set__(self, lhs): # <<<<<<<<<<<<<<
+ * if not isinstance(lhs, NT):
+ * lhs = NT(lhs)
+ */
+
+static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_lhs) {
int __pyx_r;
__Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_t_2;
+ int __pyx_t_3;
+ PyObject *__pyx_t_4 = NULL;
+ char *__pyx_t_5;
int __pyx_lineno = 0;
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_Weights))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- __Pyx_GOTREF(__pyx_v_self->weights);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->weights));
- __pyx_v_self->weights = ((struct __pyx_obj_5_cdec_Weights *)__pyx_v_value);
+ __Pyx_INCREF(__pyx_v_lhs);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":160
+ *
+ * def __set__(self, lhs):
+ * if not isinstance(lhs, NT): # <<<<<<<<<<<<<<
+ * lhs = NT(lhs)
+ * self.rule.get().lhs_ = -TDConvert(<char *>lhs.cat)
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT));
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_lhs, __pyx_t_1);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_t_3 = (!__pyx_t_2);
+ if (__pyx_t_3) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":161
+ * def __set__(self, lhs):
+ * if not isinstance(lhs, NT):
+ * lhs = NT(lhs) # <<<<<<<<<<<<<<
+ * self.rule.get().lhs_ = -TDConvert(<char *>lhs.cat)
+ *
+ */
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_INCREF(__pyx_v_lhs);
+ PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_lhs);
+ __Pyx_GIVEREF(__pyx_v_lhs);
+ __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+ __Pyx_DECREF(__pyx_v_lhs);
+ __pyx_v_lhs = __pyx_t_4;
+ __pyx_t_4 = 0;
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":162
+ * if not isinstance(lhs, NT):
+ * lhs = NT(lhs)
+ * self.rule.get().lhs_ = -TDConvert(<char *>lhs.cat) # <<<<<<<<<<<<<<
+ *
+ * def __str__(self):
+ */
+ __pyx_t_4 = PyObject_GetAttr(__pyx_v_lhs, __pyx_n_s__cat); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 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_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
- __Pyx_AddTraceback("_cdec.Decoder.weights.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_AddTraceback("_cdec.TRule.lhs.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_lhs);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_5TRule_5__str__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_5TRule_5__str__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_5TRule_4__str__(((struct __pyx_obj_5_cdec_TRule *)__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 */
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":165
+ *
+ * def __str__(self):
+ * scores = ' '.join('%s=%s' % feat for feat in self.scores) # <<<<<<<<<<<<<<
+ * return '%s ||| %s ||| %s ||| %s' % (self.lhs,
+ * _phrase(self.f), _phrase(self.e), scores)
+ */
+
+static PyObject *__pyx_pf_5_cdec_5TRule_7__str___genexpr(PyObject *__pyx_self) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *__pyx_cur_scope;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ 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_6_genexpr *)__pyx_ptype_5_cdec___pyx_scope_struct_6_genexpr->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_6_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_5___str__ *) __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_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.TRule.__str__.genexpr", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator18(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+ struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *)__pyx_generator->closure);
+ PyObject *__pyx_r = NULL;
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ Py_ssize_t __pyx_t_3;
+ PyObject *(*__pyx_t_4)(PyObject *);
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("None", 0);
+ switch (__pyx_generator->resume_label) {
+ case 0: goto __pyx_L3_first_run;
+ case 1: goto __pyx_L6_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[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
+ __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self), __pyx_n_s__scores); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
+ __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
+ __pyx_t_4 = NULL;
+ } else {
+ __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
+ }
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ for (;;) {
+ if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
+ if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
+ #else
+ __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
+ if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
+ #else
+ __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_1 = __pyx_t_4(__pyx_t_2);
+ if (unlikely(!__pyx_t_1)) {
+ if (PyErr_Occurred()) {
+ if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
+ else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_1);
+ }
+ __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_feat);
+ __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_feat);
+ __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_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_r = ((PyObject *)__pyx_t_1);
+ __pyx_t_1 = 0;
+ __Pyx_XGIVEREF(__pyx_t_2);
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
+ __pyx_cur_scope->__pyx_t_2 = __pyx_t_4;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 1;
+ return __pyx_r;
+ __pyx_L6_resume_from_yield:;
+ __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
+ __pyx_cur_scope->__pyx_t_0 = 0;
+ __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;}
+ }
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ PyErr_SetNone(PyExc_StopIteration);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_2);
+ __Pyx_AddTraceback("genexpr", __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;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":164
+ * self.rule.get().lhs_ = -TDConvert(<char *>lhs.cat)
+ *
+ * def __str__(self): # <<<<<<<<<<<<<<
+ * scores = ' '.join('%s=%s' % feat for feat in self.scores)
+ * return '%s ||| %s ||| %s ||| %s' % (self.lhs,
+ */
+
+static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *__pyx_cur_scope;
+ PyObject *__pyx_v_scores = NULL;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ PyObject *__pyx_t_4 = NULL;
+ PyObject *__pyx_t_5 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__str__", 0);
+ __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *)__pyx_ptype_5_cdec___pyx_scope_struct_5___str__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_5___str__, __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);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":165
+ *
+ * def __str__(self):
+ * scores = ' '.join('%s=%s' % feat for feat in self.scores) # <<<<<<<<<<<<<<
+ * return '%s ||| %s ||| %s ||| %s' % (self.lhs,
+ * _phrase(self.f), _phrase(self.e), scores)
+ */
+ __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_7), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __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_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_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_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
+ * 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_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_GOTREF(__pyx_t_2);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":167
+ * scores = ' '.join('%s=%s' % feat for feat in self.scores)
+ * return '%s ||| %s ||| %s ||| %s' % (self.lhs,
+ * _phrase(self.f), _phrase(self.e), scores) # <<<<<<<<<<<<<<
+ *
+ * cdef class MRule(TRule):
+ */
+ __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__f); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
+ __Pyx_GIVEREF(__pyx_t_1);
+ __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+ __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__e); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
+ __Pyx_GIVEREF(__pyx_t_3);
+ __pyx_t_3 = 0;
+ __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
+ __Pyx_GIVEREF(__pyx_t_2);
+ PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
+ __Pyx_GIVEREF(__pyx_t_1);
+ PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
+ __Pyx_GIVEREF(__pyx_t_3);
+ __Pyx_INCREF(__pyx_v_scores);
+ PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_scores);
+ __Pyx_GIVEREF(__pyx_v_scores);
+ __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_GOTREF(((PyObject *)__pyx_t_3));
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ __pyx_r = ((PyObject *)__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_2);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_XDECREF(__pyx_t_5);
+ __Pyx_AddTraceback("_cdec.TRule.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_scores);
+ __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
+ __Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
-static int __pyx_pw_5_cdec_7Decoder_7weights_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_5_cdec_7Decoder_7weights_5__del__(PyObject *__pyx_v_self) {
+static int __pyx_pw_5_cdec_5MRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5_cdec_5MRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ PyObject *__pyx_v_lhs = 0;
+ PyObject *__pyx_v_rhs = 0;
+ PyObject *__pyx_v_scores = 0;
+ PyObject *__pyx_v_a = 0;
int __pyx_r;
__Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_7Decoder_7weights_4__del__(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self));
+ __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+ {
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__lhs,&__pyx_n_s__rhs,&__pyx_n_s__scores,&__pyx_n_s__a,0};
+ PyObject* values[4] = {0,0,0,0};
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":170
+ *
+ * cdef class MRule(TRule):
+ * def __init__(self, lhs, rhs, scores, a=None): # <<<<<<<<<<<<<<
+ * cdef unsigned i = 1
+ * e = []
+ */
+ values[3] = ((PyObject *)Py_None);
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args;
+ const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+ switch (pos_args) {
+ case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+ case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+ case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ kw_args = PyDict_Size(__pyx_kwds);
+ switch (pos_args) {
+ case 0:
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lhs)) != 0)) kw_args--;
+ else goto __pyx_L5_argtuple_error;
+ case 1:
+ if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__rhs)) != 0)) kw_args--;
+ else {
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ case 2:
+ if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scores)) != 0)) kw_args--;
+ else {
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ case 3:
+ if (kw_args > 0) {
+ PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__a);
+ if (value) { values[3] = value; kw_args--; }
+ }
+ }
+ if (unlikely(kw_args > 0)) {
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ } else {
+ switch (PyTuple_GET_SIZE(__pyx_args)) {
+ case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+ case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+ values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ }
+ __pyx_v_lhs = values[0];
+ __pyx_v_rhs = values[1];
+ __pyx_v_scores = values[2];
+ __pyx_v_a = values[3];
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L5_argtuple_error:;
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("_cdec.MRule.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return -1;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_5MRule___init__(((struct __pyx_obj_5_cdec_MRule *)__pyx_v_self), __pyx_v_lhs, __pyx_v_rhs, __pyx_v_scores, __pyx_v_a);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-static int __pyx_pf_5_cdec_7Decoder_7weights_4__del__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self) {
+static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_rhs, PyObject *__pyx_v_scores, PyObject *__pyx_v_a) {
+ unsigned int __pyx_v_i;
+ PyObject *__pyx_v_e = NULL;
+ PyObject *__pyx_v_s = NULL;
int __pyx_r;
__Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__del__", 0);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GOTREF(__pyx_v_self->weights);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->weights));
- __pyx_v_self->weights = ((struct __pyx_obj_5_cdec_Weights *)Py_None);
+ PyObject *__pyx_t_1 = NULL;
+ Py_ssize_t __pyx_t_2;
+ PyObject *(*__pyx_t_3)(PyObject *);
+ PyObject *__pyx_t_4 = NULL;
+ int __pyx_t_5;
+ PyObject *__pyx_t_6 = NULL;
+ int __pyx_t_7;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__init__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":171
+ * cdef class MRule(TRule):
+ * def __init__(self, lhs, rhs, scores, a=None):
+ * cdef unsigned i = 1 # <<<<<<<<<<<<<<
+ * e = []
+ * for s in rhs:
+ */
+ __pyx_v_i = 1;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":172
+ * def __init__(self, lhs, rhs, scores, a=None):
+ * cdef unsigned i = 1
+ * e = [] # <<<<<<<<<<<<<<
+ * for s in rhs:
+ * if isinstance(s, NT):
+ */
+ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_v_e = __pyx_t_1;
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":173
+ * cdef unsigned i = 1
+ * e = []
+ * for s in rhs: # <<<<<<<<<<<<<<
+ * if isinstance(s, NT):
+ * e.append(NTRef(i))
+ */
+ if (PyList_CheckExact(__pyx_v_rhs) || PyTuple_CheckExact(__pyx_v_rhs)) {
+ __pyx_t_1 = __pyx_v_rhs; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+ __pyx_t_3 = NULL;
+ } else {
+ __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
+ }
+ for (;;) {
+ if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
+ #else
+ __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
+ #else
+ __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_4 = __pyx_t_3(__pyx_t_1);
+ if (unlikely(!__pyx_t_4)) {
+ if (PyErr_Occurred()) {
+ if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
+ else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_4);
+ }
+ __Pyx_XDECREF(__pyx_v_s);
+ __pyx_v_s = __pyx_t_4;
+ __pyx_t_4 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":174
+ * e = []
+ * for s in rhs:
+ * if isinstance(s, NT): # <<<<<<<<<<<<<<
+ * e.append(NTRef(i))
+ * i += 1
+ */
+ __pyx_t_4 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT));
+ __Pyx_INCREF(__pyx_t_4);
+ __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_s, __pyx_t_4);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ if (__pyx_t_5) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":175
+ * for s in rhs:
+ * if isinstance(s, NT):
+ * e.append(NTRef(i)) # <<<<<<<<<<<<<<
+ * i += 1
+ * else:
+ */
+ __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
+ __Pyx_GIVEREF(__pyx_t_4);
+ __pyx_t_4 = 0;
+ __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+ __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":176
+ * if isinstance(s, NT):
+ * e.append(NTRef(i))
+ * i += 1 # <<<<<<<<<<<<<<
+ * else:
+ * e.append(s)
+ */
+ __pyx_v_i = (__pyx_v_i + 1);
+ goto __pyx_L5;
+ }
+ /*else*/ {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":178
+ * i += 1
+ * else:
+ * e.append(s) # <<<<<<<<<<<<<<
+ * super(MRule, self).__init__(lhs, rhs, e, scores, a)
+ *
+ */
+ __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_v_s); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ __pyx_L5:;
+ }
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":179
+ * else:
+ * e.append(s)
+ * super(MRule, self).__init__(lhs, rhs, e, scores, a) # <<<<<<<<<<<<<<
+ *
+ * cdef class Grammar:
+ */
+ __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_MRule)));
+ PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_MRule)));
+ __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_MRule)));
+ __Pyx_INCREF(((PyObject *)__pyx_v_self));
+ PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self));
+ __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
+ __pyx_t_4 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __pyx_t_4 = PyTuple_New(5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_INCREF(__pyx_v_lhs);
+ PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_lhs);
+ __Pyx_GIVEREF(__pyx_v_lhs);
+ __Pyx_INCREF(__pyx_v_rhs);
+ PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_rhs);
+ __Pyx_GIVEREF(__pyx_v_rhs);
+ __Pyx_INCREF(((PyObject *)__pyx_v_e));
+ PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_e));
+ __Pyx_GIVEREF(((PyObject *)__pyx_v_e));
+ __Pyx_INCREF(__pyx_v_scores);
+ PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_scores);
+ __Pyx_GIVEREF(__pyx_v_scores);
+ __Pyx_INCREF(__pyx_v_a);
+ PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_v_a);
+ __Pyx_GIVEREF(__pyx_v_a);
+ __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_AddTraceback("_cdec.MRule.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_e);
+ __Pyx_XDECREF(__pyx_v_s);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static void __pyx_pw_5_cdec_7Grammar_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_5_cdec_7Grammar_1__dealloc__(PyObject *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+ __pyx_pf_5_cdec_7Grammar___dealloc__(((struct __pyx_obj_5_cdec_Grammar *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":184
+ * cdef shared_ptr[grammar.Grammar]* grammar
+ *
+ * def __dealloc__(self): # <<<<<<<<<<<<<<
+ * del self.grammar
+ *
+ */
+
+static void __pyx_pf_5_cdec_7Grammar___dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Grammar *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":185
+ *
+ * def __dealloc__(self):
+ * del self.grammar # <<<<<<<<<<<<<<
+ *
+ * def __iter__(self):
+ */
+ delete __pyx_v_self->grammar;
+
+ __Pyx_RefNannyFinishContext();
+}
+static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_7Grammar_3__iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_7Grammar_3__iter__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_7Grammar_2__iter__(((struct __pyx_obj_5_cdec_Grammar *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":187
+ * del self.grammar
+ *
+ * def __iter__(self): # <<<<<<<<<<<<<<
+ * cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot()
+ * cdef grammar.const_RuleBin* rbin = root.GetRules()
+ */
+
+static PyObject *__pyx_pf_5_cdec_7Grammar_2__iter__(struct __pyx_obj_5_cdec_Grammar *__pyx_v_self) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_7___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_7___iter__ *)__pyx_ptype_5_cdec___pyx_scope_struct_7___iter__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_7___iter__, __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_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Grammar_4generator3, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_cur_scope);
+ __Pyx_RefNannyFinishContext();
+ return (PyObject *) gen;
+ }
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.Grammar.__iter__", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+ struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ *)__pyx_generator->closure);
+ PyObject *__pyx_r = NULL;
+ int __pyx_t_1;
+ unsigned int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("None", 0);
+ switch (__pyx_generator->resume_label) {
+ case 0: goto __pyx_L3_first_run;
+ case 1: goto __pyx_L6_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[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":188
+ *
+ * def __iter__(self):
+ * cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot() # <<<<<<<<<<<<<<
+ * cdef grammar.const_RuleBin* rbin = root.GetRules()
+ * cdef TRule trule
+ */
+ __pyx_cur_scope->__pyx_v_root = __pyx_cur_scope->__pyx_v_self->grammar->get()->GetRoot();
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":189
+ * def __iter__(self):
+ * cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot()
+ * cdef grammar.const_RuleBin* rbin = root.GetRules() # <<<<<<<<<<<<<<
+ * cdef TRule trule
+ * cdef unsigned i
+ */
+ __pyx_cur_scope->__pyx_v_rbin = __pyx_cur_scope->__pyx_v_root->GetRules();
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":192
+ * cdef TRule trule
+ * cdef unsigned i
+ * for i in range(rbin.GetNumRules()): # <<<<<<<<<<<<<<
+ * trule = TRule.__new__(TRule)
+ * trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i))
+ */
+ __pyx_t_1 = __pyx_cur_scope->__pyx_v_rbin->GetNumRules();
+ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
+ __pyx_cur_scope->__pyx_v_i = __pyx_t_2;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":193
+ * cdef unsigned i
+ * for i in range(rbin.GetNumRules()):
+ * trule = TRule.__new__(TRule) # <<<<<<<<<<<<<<
+ * trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i))
+ * yield trule
+ */
+ __pyx_t_3 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_TRule)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_trule));
+ __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_trule));
+ __Pyx_GIVEREF(__pyx_t_3);
+ __pyx_cur_scope->__pyx_v_trule = ((struct __pyx_obj_5_cdec_TRule *)__pyx_t_3);
+ __pyx_t_3 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":194
+ * for i in range(rbin.GetNumRules()):
+ * trule = TRule.__new__(TRule)
+ * trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i)) # <<<<<<<<<<<<<<
+ * yield trule
+ *
+ */
+ __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
+ * trule = TRule.__new__(TRule)
+ * trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i))
+ * yield trule # <<<<<<<<<<<<<<
+ *
+ * property name:
+ */
+ __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_trule));
+ __pyx_r = ((PyObject *)__pyx_cur_scope->__pyx_v_trule);
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 1;
+ return __pyx_r;
+ __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;}
+ }
+ PyErr_SetNone(PyExc_StopIteration);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("__iter__", __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_7Grammar_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_7Grammar_4name_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_7Grammar_4name___get__(((struct __pyx_obj_5_cdec_Grammar *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":198
+ *
+ * property name:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * 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
+ __Pyx_RefNannySetupContext("__get__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":199
+ * property name:
+ * def __get__(self):
+ * self.grammar.get().GetGrammarName().c_str() # <<<<<<<<<<<<<<
+ *
+ * def __set__(self, name):
+ */
+ __pyx_v_self->grammar->get()->GetGrammarName().c_str();
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_7Grammar_4name_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
+static int __pyx_pw_5_cdec_7Grammar_4name_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_name) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_7Grammar_4name_2__set__(((struct __pyx_obj_5_cdec_Grammar *)__pyx_v_self), ((PyObject *)__pyx_v_name));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":201
+ * self.grammar.get().GetGrammarName().c_str()
+ *
+ * def __set__(self, name): # <<<<<<<<<<<<<<
+ * self.grammar.get().SetGrammarName(string(<char *>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;
+ 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":202
+ *
+ * def __set__(self, name):
+ * self.grammar.get().SetGrammarName(string(<char *>name)) # <<<<<<<<<<<<<<
+ *
+ * cdef class TextGrammar(Grammar):
+ */
+ __pyx_t_1 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_self->grammar->get()->SetGrammarName(std::string(((char *)__pyx_t_1)));
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.Grammar.name.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __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) {
+ PyObject *__pyx_v_rules = 0;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
+ {
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__rules,0};
+ PyObject* values[1] = {0};
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args;
+ const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+ switch (pos_args) {
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ kw_args = PyDict_Size(__pyx_kwds);
+ switch (pos_args) {
+ case 0:
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__rules)) != 0)) kw_args--;
+ else goto __pyx_L5_argtuple_error;
+ }
+ if (unlikely(kw_args > 0)) {
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __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_rules = values[0];
+ }
+ 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_L3_error:;
+ __Pyx_AddTraceback("_cdec.TextGrammar.__cinit__", __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_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":205
+ *
+ * cdef class TextGrammar(Grammar):
+ * def __cinit__(self, 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) {
+ TextGrammar *__pyx_v__g;
+ PyObject *__pyx_v_trule = NULL;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ Py_ssize_t __pyx_t_2;
+ PyObject *(*__pyx_t_3)(PyObject *);
+ PyObject *__pyx_t_4 = NULL;
+ int __pyx_t_5;
+ PyObject *__pyx_t_6 = NULL;
+ int __pyx_t_7;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__cinit__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":206
+ * cdef class TextGrammar(Grammar):
+ * def __cinit__(self, rules):
+ * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) # <<<<<<<<<<<<<<
+ * 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):
+ * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar())
+ * cdef grammar.TextGrammar* _g = <grammar.TextGrammar*> self.grammar.get() # <<<<<<<<<<<<<<
+ * for trule in rules:
+ * if isinstance(trule, _sa.Rule):
+ */
+ __pyx_v__g = ((TextGrammar *)__pyx_v_self->__pyx_base.grammar->get());
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":208
+ * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar())
+ * cdef grammar.TextGrammar* _g = <grammar.TextGrammar*> self.grammar.get()
+ * for trule in rules: # <<<<<<<<<<<<<<
+ * if isinstance(trule, _sa.Rule):
+ * trule = convert_rule(trule)
+ */
+ if (PyList_CheckExact(__pyx_v_rules) || PyTuple_CheckExact(__pyx_v_rules)) {
+ __pyx_t_1 = __pyx_v_rules; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
+ __pyx_t_3 = NULL;
+ } else {
+ __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rules); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
+ }
+ for (;;) {
+ if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
+ #else
+ __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
+ #else
+ __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_4 = __pyx_t_3(__pyx_t_1);
+ if (unlikely(!__pyx_t_4)) {
+ if (PyErr_Occurred()) {
+ if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
+ else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_4);
+ }
+ __Pyx_XDECREF(__pyx_v_trule);
+ __pyx_v_trule = __pyx_t_4;
+ __pyx_t_4 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":209
+ * cdef grammar.TextGrammar* _g = <grammar.TextGrammar*> self.grammar.get()
+ * for trule in rules:
+ * if isinstance(trule, _sa.Rule): # <<<<<<<<<<<<<<
+ * trule = convert_rule(trule)
+ * elif not isinstance(trule, TRule):
+ */
+ __pyx_t_4 = ((PyObject *)((PyObject*)__pyx_ptype_4cdec_2sa_3_sa_Rule));
+ __Pyx_INCREF(__pyx_t_4);
+ __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_trule, __pyx_t_4);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ if (__pyx_t_5) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":210
+ * for trule in rules:
+ * if isinstance(trule, _sa.Rule):
+ * trule = convert_rule(trule) # <<<<<<<<<<<<<<
+ * elif not isinstance(trule, TRule):
+ * raise ValueError('the grammar should contain TRule objects')
+ */
+ if (!(likely(((__pyx_v_trule) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_trule, __pyx_ptype_4cdec_2sa_3_sa_Rule))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __pyx_v_trule;
+ __Pyx_INCREF(__pyx_t_4);
+ __pyx_t_6 = ((PyObject *)__pyx_f_5_cdec_convert_rule(((struct __pyx_obj_4cdec_2sa_3_sa_Rule *)__pyx_t_4))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __Pyx_DECREF(__pyx_v_trule);
+ __pyx_v_trule = __pyx_t_6;
+ __pyx_t_6 = 0;
+ goto __pyx_L5;
+ }
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":211
+ * if isinstance(trule, _sa.Rule):
+ * trule = convert_rule(trule)
+ * elif not isinstance(trule, TRule): # <<<<<<<<<<<<<<
+ * raise ValueError('the grammar should contain TRule objects')
+ * _g.AddRule((<TRule> trule).rule[0])
+ */
+ __pyx_t_6 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TRule));
+ __Pyx_INCREF(__pyx_t_6);
+ __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_trule, __pyx_t_6);
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __pyx_t_7 = (!__pyx_t_5);
+ if (__pyx_t_7) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":212
+ * trule = convert_rule(trule)
+ * elif not isinstance(trule, TRule):
+ * raise ValueError('the grammar should contain TRule objects') # <<<<<<<<<<<<<<
+ * _g.AddRule((<TRule> trule).rule[0])
+ */
+ __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __Pyx_Raise(__pyx_t_6, 0, 0, 0);
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ {__pyx_filename = __pyx_f[2]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ goto __pyx_L5;
+ }
+ __pyx_L5:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":213
+ * elif not isinstance(trule, TRule):
+ * raise ValueError('the grammar should contain TRule objects')
+ * _g.AddRule((<TRule> trule).rule[0]) # <<<<<<<<<<<<<<
+ */
+ __pyx_v__g->AddRule((((struct __pyx_obj_5_cdec_TRule *)__pyx_v_trule)->rule[0]));
+ }
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_AddTraceback("_cdec.TextGrammar.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_trule);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
@@ -2020,7 +8592,7 @@ static void __pyx_pw_5_cdec_10Hypergraph_1__dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannyFinishContext();
}
-/* "_cdec.pyx":75
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":8
* cdef MT19937* rng
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
@@ -2033,7 +8605,7 @@ static void __pyx_pf_5_cdec_10Hypergraph___dealloc__(struct __pyx_obj_5_cdec_Hyp
int __pyx_t_1;
__Pyx_RefNannySetupContext("__dealloc__", 0);
- /* "_cdec.pyx":76
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":9
*
* def __dealloc__(self):
* del self.hg # <<<<<<<<<<<<<<
@@ -2042,7 +8614,7 @@ static void __pyx_pf_5_cdec_10Hypergraph___dealloc__(struct __pyx_obj_5_cdec_Hyp
*/
delete __pyx_v_self->hg;
- /* "_cdec.pyx":77
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":10
* def __dealloc__(self):
* del self.hg
* if self.rng != NULL: # <<<<<<<<<<<<<<
@@ -2052,7 +8624,7 @@ 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) {
- /* "_cdec.pyx":78
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":11
* del self.hg
* if self.rng != NULL:
* del self.rng # <<<<<<<<<<<<<<
@@ -2078,17 +8650,16 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_3viterbi(PyObject *__pyx_v_self, C
return __pyx_r;
}
-/* "_cdec.pyx":80
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":13
* del self.rng
*
* def viterbi(self): # <<<<<<<<<<<<<<
- * assert (self.hg != NULL)
* 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) {
std::vector<WordID> __pyx_v_trans;
- PyObject *__pyx_v_sentence = 0;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
@@ -2098,57 +8669,38 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_H
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("viterbi", 0);
- /* "_cdec.pyx":81
- *
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":15
* def viterbi(self):
- * assert (self.hg != NULL) # <<<<<<<<<<<<<<
- * cdef vector[WordID] trans
- * hypergraph.ViterbiESentence(self.hg[0], &trans)
- */
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!(__pyx_v_self->hg != NULL))) {
- PyErr_SetNone(PyExc_AssertionError);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
- #endif
-
- /* "_cdec.pyx":83
- * assert (self.hg != NULL)
* cdef vector[WordID] trans
* hypergraph.ViterbiESentence(self.hg[0], &trans) # <<<<<<<<<<<<<<
- * cdef str sentence = GetString(trans).c_str()
- * return sentence.decode('utf8')
+ * return unicode(GetString(trans).c_str(), 'utf8')
+ *
*/
ViterbiESentence((__pyx_v_self->hg[0]), (&__pyx_v_trans));
- /* "_cdec.pyx":84
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":16
* cdef vector[WordID] trans
* hypergraph.ViterbiESentence(self.hg[0], &trans)
- * cdef str sentence = GetString(trans).c_str() # <<<<<<<<<<<<<<
- * return sentence.decode('utf8')
+ * return unicode(GetString(trans).c_str(), 'utf8') # <<<<<<<<<<<<<<
*
+ * def viterbi_trees(self):
*/
- __pyx_t_1 = PyBytes_FromString(TD::GetString(__pyx_v_trans).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __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_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[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_v_sentence = ((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_GOTREF(__pyx_t_2);
+ PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
+ PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__utf8));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
__pyx_t_1 = 0;
-
- /* "_cdec.pyx":85
- * hypergraph.ViterbiESentence(self.hg[0], &trans)
- * cdef str sentence = GetString(trans).c_str()
- * return sentence.decode('utf8') # <<<<<<<<<<<<<<
- *
- * def viterbi_tree(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_sentence), __pyx_n_s__decode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __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 = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __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;
- __pyx_t_2 = 0;
+ __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);
@@ -2159,33 +8711,33 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_H
__Pyx_AddTraceback("_cdec.Hypergraph.viterbi", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
- __Pyx_XDECREF(__pyx_v_sentence);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_10Hypergraph_5viterbi_tree(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_5_cdec_10Hypergraph_5viterbi_tree(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_5viterbi_trees(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_5viterbi_trees(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("viterbi_tree (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_10Hypergraph_4viterbi_tree(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self));
+ __Pyx_RefNannySetupContext("viterbi_trees (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "_cdec.pyx":87
- * return sentence.decode('utf8')
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":18
+ * return unicode(GetString(trans).c_str(), 'utf8')
*
- * def viterbi_tree(self): # <<<<<<<<<<<<<<
- * assert (self.hg != NULL)
- * cdef str tree = hypergraph.ViterbiETree(self.hg[0]).c_str()
+ * 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')
*/
-static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_tree(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) {
- PyObject *__pyx_v_tree = 0;
+static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) {
+ PyObject *__pyx_v_f_tree = NULL;
+ PyObject *__pyx_v_e_tree = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
@@ -2193,50 +8745,217 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_tree(struct __pyx_obj_5_c
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("viterbi_tree", 0);
+ __Pyx_RefNannySetupContext("viterbi_trees", 0);
- /* "_cdec.pyx":88
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":19
*
- * def viterbi_tree(self):
- * assert (self.hg != NULL) # <<<<<<<<<<<<<<
- * cdef str tree = hypergraph.ViterbiETree(self.hg[0]).c_str()
- * return tree.decode('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')
+ * return (f_tree, e_tree)
*/
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!(__pyx_v_self->hg != NULL))) {
- PyErr_SetNone(PyExc_AssertionError);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
- #endif
+ __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_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_GOTREF(__pyx_t_2);
+ PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
+ 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_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;
- /* "_cdec.pyx":89
- * def viterbi_tree(self):
- * assert (self.hg != NULL)
- * cdef str tree = hypergraph.ViterbiETree(self.hg[0]).c_str() # <<<<<<<<<<<<<<
- * return tree.decode('utf8')
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":20
+ * 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') # <<<<<<<<<<<<<<
+ * 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[0]; __pyx_lineno = 89; __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 = 20; __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[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_v_tree = ((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_GOTREF(__pyx_t_2);
+ PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
+ 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_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;
- /* "_cdec.pyx":90
- * assert (self.hg != NULL)
- * cdef str tree = hypergraph.ViterbiETree(self.hg[0]).c_str()
- * return tree.decode('utf8') # <<<<<<<<<<<<<<
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":21
+ * 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) # <<<<<<<<<<<<<<
*
- * def kbest(self, size):
+ * def viterbi_features(self):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_tree), __pyx_n_s__decode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __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 = 21; __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));
+ __Pyx_GIVEREF(((PyObject *)__pyx_v_f_tree));
+ __Pyx_INCREF(((PyObject *)__pyx_v_e_tree));
+ PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_e_tree));
+ __Pyx_GIVEREF(((PyObject *)__pyx_v_e_tree));
+ __pyx_r = ((PyObject *)__pyx_t_1);
+ __pyx_t_1 = 0;
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_2);
+ __Pyx_AddTraceback("_cdec.Hypergraph.viterbi_trees", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_f_tree);
+ __Pyx_XDECREF(__pyx_v_e_tree);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_7viterbi_features(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_7viterbi_features(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("viterbi_features (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_10Hypergraph_6viterbi_features(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":23
+ * 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]))
+ */
+
+static PyObject *__pyx_pf_5_cdec_10Hypergraph_6viterbi_features(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) {
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_fmap = 0;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("viterbi_features", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":24
+ *
+ * def viterbi_features(self):
+ * 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_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __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 = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_fmap = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":25
+ * def viterbi_features(self):
+ * cdef SparseVector fmap = SparseVector.__new__(SparseVector)
+ * fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0])) # <<<<<<<<<<<<<<
+ * return fmap
+ *
+ */
+ __pyx_v_fmap->vector = new FastSparseVector<weight_t>(ViterbiFeatures((__pyx_v_self->hg[0])));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":26
+ * cdef SparseVector fmap = SparseVector.__new__(SparseVector)
+ * fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0]))
+ * return fmap # <<<<<<<<<<<<<<
+ *
+ * def viterbi_joshua(self):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_fmap));
+ __pyx_r = ((PyObject *)__pyx_v_fmap);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.Hypergraph.viterbi_features", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_fmap);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_9viterbi_joshua(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_9viterbi_joshua(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("viterbi_joshua (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_10Hypergraph_8viterbi_joshua(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":28
+ * return fmap
+ *
+ * def viterbi_joshua(self): # <<<<<<<<<<<<<<
+ * 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) {
+ 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("viterbi_joshua", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":29
+ *
+ * def viterbi_joshua(self):
+ * 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_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_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
+ PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
+ 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_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);
@@ -2244,44 +8963,43 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_tree(struct __pyx_obj_5_c
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("_cdec.Hypergraph.viterbi_tree", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.Hypergraph.viterbi_joshua", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
- __Pyx_XDECREF(__pyx_v_tree);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_10Hypergraph_8generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_10Hypergraph_7kbest(PyObject *__pyx_v_self, PyObject *__pyx_v_size); /*proto*/
-static PyObject *__pyx_pw_5_cdec_10Hypergraph_7kbest(PyObject *__pyx_v_self, PyObject *__pyx_v_size) {
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_11kbest(PyObject *__pyx_v_self, PyObject *__pyx_v_size); /*proto*/
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_11kbest(PyObject *__pyx_v_self, PyObject *__pyx_v_size) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("kbest (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_10Hypergraph_6kbest(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((PyObject *)__pyx_v_size));
+ __pyx_r = __pyx_pf_5_cdec_10Hypergraph_10kbest(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((PyObject *)__pyx_v_size));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "_cdec.pyx":92
- * return tree.decode('utf8')
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":31
+ * return unicode(hypergraph.JoshuaVisualizationString(self.hg[0]).c_str(), 'utf8')
*
* def kbest(self, size): # <<<<<<<<<<<<<<
- * assert (self.hg != NULL)
- * cdef kb.KBestDerivations[vector[WordID], kb.ESentenceTraversal]* derivations = new kb.KBestDerivations[vector[WordID], kb.ESentenceTraversal](self.hg[0], size)
+ * 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_6kbest(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest *__pyx_cur_scope;
+static PyObject *__pyx_pf_5_cdec_10Hypergraph_10kbest(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("kbest", 0);
- __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest *)__pyx_ptype_5_cdec___pyx_scope_struct_1_kbest->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_1_kbest, __pyx_empty_tuple, NULL);
+ __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest *)__pyx_ptype_5_cdec___pyx_scope_struct_8_kbest->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_8_kbest, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__Pyx_RefNannyFinishContext();
return NULL;
@@ -2294,7 +9012,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6kbest(struct __pyx_obj_5_cdec_Hyp
__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_8generator1, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __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 = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -2312,9 +9030,9 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6kbest(struct __pyx_obj_5_cdec_Hyp
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_10Hypergraph_8generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
- struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest *)__pyx_generator->closure);
+ struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest *)__pyx_generator->closure);
PyObject *__pyx_r = NULL;
unsigned int __pyx_t_1;
long __pyx_t_2;
@@ -2325,124 +9043,138 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_8generator1(__pyx_GeneratorObject
__Pyx_RefNannySetupContext("None", 0);
switch (__pyx_generator->resume_label) {
case 0: goto __pyx_L3_first_run;
- case 1: goto __pyx_L7_resume_from_yield;
+ case 1: goto __pyx_L10_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[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- /* "_cdec.pyx":93
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":32
*
* def kbest(self, size):
- * assert (self.hg != NULL) # <<<<<<<<<<<<<<
- * cdef kb.KBestDerivations[vector[WordID], kb.ESentenceTraversal]* derivations = new kb.KBestDerivations[vector[WordID], kb.ESentenceTraversal](self.hg[0], size)
- * cdef kb.KBestDerivations[vector[WordID], kb.ESentenceTraversal].Derivation* derivation
- */
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!(__pyx_cur_scope->__pyx_v_self->hg != NULL))) {
- PyErr_SetNone(PyExc_AssertionError);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
- #endif
-
- /* "_cdec.pyx":94
- * def kbest(self, size):
- * assert (self.hg != NULL)
- * cdef kb.KBestDerivations[vector[WordID], kb.ESentenceTraversal]* derivations = new kb.KBestDerivations[vector[WordID], kb.ESentenceTraversal](self.hg[0], size) # <<<<<<<<<<<<<<
- * cdef kb.KBestDerivations[vector[WordID], kb.ESentenceTraversal].Derivation* derivation
- * cdef str tree
+ * 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[0]; __pyx_lineno = 94; __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 = 32; __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);
- /* "_cdec.pyx":98
- * cdef str tree
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":35
+ * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal].Derivation* derivation
* cdef unsigned k
- * for k in range(size): # <<<<<<<<<<<<<<
- * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k)
- * if not derivation: break
+ * try: # <<<<<<<<<<<<<<
+ * for k in range(size):
+ * derivation = 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[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_2; __pyx_t_1+=1) {
- __pyx_cur_scope->__pyx_v_k = __pyx_t_1;
+ /*try:*/ {
- /* "_cdec.pyx":99
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":36
* cdef unsigned k
- * for k in range(size):
- * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) # <<<<<<<<<<<<<<
- * if not derivation: break
- * tree = GetString(derivation._yield).c_str()
+ * try:
+ * for k in range(size): # <<<<<<<<<<<<<<
+ * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k)
+ * if not derivation: break
*/
- __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);
-
- /* "_cdec.pyx":100
- * for k in range(size):
- * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k)
- * if not derivation: break # <<<<<<<<<<<<<<
- * tree = GetString(derivation._yield).c_str()
- * yield tree.decode('utf8')
+ __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;}
+ 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
+ * try:
+ * for k in range(size):
+ * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) # <<<<<<<<<<<<<<
+ * if not derivation: break
+ * yield unicode(GetString(derivation._yield).c_str(), 'utf8')
*/
- __pyx_t_3 = (!(__pyx_cur_scope->__pyx_v_derivation != 0));
- if (__pyx_t_3) {
- goto __pyx_L5_break;
- goto __pyx_L6;
- }
- __pyx_L6:;
-
- /* "_cdec.pyx":101
- * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k)
- * if not derivation: break
- * tree = GetString(derivation._yield).c_str() # <<<<<<<<<<<<<<
- * yield tree.decode('utf8')
- * del derivations
+ __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
+ * for k in range(size):
+ * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k)
+ * if not derivation: break # <<<<<<<<<<<<<<
+ * yield unicode(GetString(derivation._yield).c_str(), 'utf8')
+ * finally:
*/
- __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[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(((PyObject *)__pyx_t_4));
- if (!(likely(PyString_CheckExact(((PyObject *)__pyx_t_4)))||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(((PyObject *)__pyx_t_4))->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_tree));
- __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_tree));
- __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
- __pyx_cur_scope->__pyx_v_tree = ((PyObject*)__pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "_cdec.pyx":102
- * if not derivation: break
- * tree = GetString(derivation._yield).c_str()
- * yield tree.decode('utf8') # <<<<<<<<<<<<<<
- * del derivations
- *
+ __pyx_t_3 = (!(__pyx_cur_scope->__pyx_v_derivation != 0));
+ if (__pyx_t_3) {
+ goto __pyx_L8_break;
+ goto __pyx_L9;
+ }
+ __pyx_L9:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":39
+ * 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 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_tree), __pyx_n_s__decode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_5;
- __pyx_t_5 = 0;
- __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
- __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- /* return from generator, yielding value */
- __pyx_generator->resume_label = 1;
- return __pyx_r;
- __pyx_L7_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[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __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_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_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 = 39; __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_1;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __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_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;}
+ }
+ __pyx_L8_break:;
}
- __pyx_L5_break:;
- /* "_cdec.pyx":103
- * tree = GetString(derivation._yield).c_str()
- * yield tree.decode('utf8')
- * del derivations # <<<<<<<<<<<<<<
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":41
+ * yield unicode(GetString(derivation._yield).c_str(), 'utf8')
+ * finally:
+ * del derivations # <<<<<<<<<<<<<<
*
- * def kbest_tree(self, size):
+ * def kbest_trees(self, size):
*/
- delete __pyx_cur_scope->__pyx_v_derivations;
+ /*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_derivations;
+ 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:;
@@ -2452,39 +9184,40 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_8generator1(__pyx_GeneratorObject
__pyx_L0:;
__Pyx_XDECREF(__pyx_r);
__pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
return NULL;
}
-static PyObject *__pyx_gb_5_cdec_10Hypergraph_11generator2(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_10Hypergraph_10kbest_tree(PyObject *__pyx_v_self, PyObject *__pyx_v_size); /*proto*/
-static PyObject *__pyx_pw_5_cdec_10Hypergraph_10kbest_tree(PyObject *__pyx_v_self, PyObject *__pyx_v_size) {
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_14kbest_trees(PyObject *__pyx_v_self, PyObject *__pyx_v_size); /*proto*/
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_14kbest_trees(PyObject *__pyx_v_self, PyObject *__pyx_v_size) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("kbest_tree (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_10Hypergraph_9kbest_tree(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((PyObject *)__pyx_v_size));
+ __Pyx_RefNannySetupContext("kbest_trees (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_10Hypergraph_13kbest_trees(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((PyObject *)__pyx_v_size));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "_cdec.pyx":105
- * del derivations
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":43
+ * del derivations
*
- * def kbest_tree(self, size): # <<<<<<<<<<<<<<
- * assert (self.hg != NULL)
- * cdef kb.KBestDerivations[vector[WordID], kb.ETreeTraversal]* derivations = new kb.KBestDerivations[vector[WordID], kb.ETreeTraversal](self.hg[0], size)
+ * def kbest_trees(self, size): # <<<<<<<<<<<<<<
+ * 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_9kbest_tree(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree *__pyx_cur_scope;
+static PyObject *__pyx_pf_5_cdec_10Hypergraph_13kbest_trees(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_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("kbest_tree", 0);
- __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree *)__pyx_ptype_5_cdec___pyx_scope_struct_2_kbest_tree->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_2_kbest_tree, __pyx_empty_tuple, NULL);
+ __Pyx_RefNannySetupContext("kbest_trees", 0);
+ __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees *)__pyx_ptype_5_cdec___pyx_scope_struct_9_kbest_trees->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_9_kbest_trees, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__Pyx_RefNannyFinishContext();
return NULL;
@@ -2497,7 +9230,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_9kbest_tree(struct __pyx_obj_5_cde
__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_11generator2, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __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 = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -2506,7 +9239,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_9kbest_tree(struct __pyx_obj_5_cde
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
- __Pyx_AddTraceback("_cdec.Hypergraph.kbest_tree", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.Hypergraph.kbest_trees", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_DECREF(((PyObject *)__pyx_cur_scope));
@@ -2515,226 +9248,485 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_9kbest_tree(struct __pyx_obj_5_cde
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_10Hypergraph_11generator2(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
- struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree *)__pyx_generator->closure);
+ struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees *)__pyx_generator->closure);
PyObject *__pyx_r = NULL;
unsigned int __pyx_t_1;
long __pyx_t_2;
int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
+ int __pyx_t_4;
+ int __pyx_t_5;
+ PyObject *__pyx_t_6 = NULL;
+ PyObject *__pyx_t_7 = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("None", 0);
switch (__pyx_generator->resume_label) {
case 0: goto __pyx_L3_first_run;
- case 1: goto __pyx_L7_resume_from_yield;
+ case 1: goto __pyx_L10_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[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- /* "_cdec.pyx":106
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":44
*
- * def kbest_tree(self, size):
- * assert (self.hg != NULL) # <<<<<<<<<<<<<<
- * cdef kb.KBestDerivations[vector[WordID], kb.ETreeTraversal]* derivations = new kb.KBestDerivations[vector[WordID], kb.ETreeTraversal](self.hg[0], size)
- * cdef kb.KBestDerivations[vector[WordID], kb.ETreeTraversal].Derivation* derivation
+ * def kbest_trees(self, size):
+ * 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)
*/
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!(__pyx_cur_scope->__pyx_v_self->hg != NULL))) {
- PyErr_SetNone(PyExc_AssertionError);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
- #endif
-
- /* "_cdec.pyx":107
- * def kbest_tree(self, size):
- * assert (self.hg != NULL)
- * cdef kb.KBestDerivations[vector[WordID], kb.ETreeTraversal]* derivations = new kb.KBestDerivations[vector[WordID], kb.ETreeTraversal](self.hg[0], size) # <<<<<<<<<<<<<<
- * cdef kb.KBestDerivations[vector[WordID], kb.ETreeTraversal].Derivation* derivation
- * cdef str sentence
+ __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_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
+ * 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[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_cur_scope->__pyx_v_derivations = new KBest::KBestDerivations<std::vector<WordID>,ETreeTraversal>((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_t_1);
+ __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_e_derivations = new KBest::KBestDerivations<std::vector<WordID>,ETreeTraversal>((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_t_1);
- /* "_cdec.pyx":111
- * cdef str sentence
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":49
+ * cdef kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal].Derivation* e_derivation
* cdef unsigned k
- * for k in range(size): # <<<<<<<<<<<<<<
- * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k)
- * if not derivation: break
+ * try: # <<<<<<<<<<<<<<
+ * for k in range(size):
+ * f_derivation = f_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[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_2; __pyx_t_1+=1) {
- __pyx_cur_scope->__pyx_v_k = __pyx_t_1;
+ /*try:*/ {
- /* "_cdec.pyx":112
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":50
* cdef unsigned k
- * for k in range(size):
- * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) # <<<<<<<<<<<<<<
- * if not derivation: break
- * sentence = GetString(derivation._yield).c_str()
+ * 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;}
+ 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
+ * 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)
+ * if not f_derivation or not e_derivation: break
*/
- __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);
+ __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
+ * 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) # <<<<<<<<<<<<<<
+ * if not f_derivation or not e_derivation: break
+ * f_tree = unicode(GetString(f_derivation._yield).c_str(), 'utf8')
+ */
+ __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
+ * 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 # <<<<<<<<<<<<<<
+ * f_tree = unicode(GetString(f_derivation._yield).c_str(), 'utf8')
+ * e_tree = unicode(GetString(e_derivation._yield).c_str(), 'utf8')
+ */
+ __pyx_t_3 = (!(__pyx_cur_scope->__pyx_v_f_derivation != 0));
+ if (!__pyx_t_3) {
+ __pyx_t_4 = (!(__pyx_cur_scope->__pyx_v_e_derivation != 0));
+ __pyx_t_5 = __pyx_t_4;
+ } else {
+ __pyx_t_5 = __pyx_t_3;
+ }
+ if (__pyx_t_5) {
+ goto __pyx_L8_break;
+ goto __pyx_L9;
+ }
+ __pyx_L9:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":54
+ * 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_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_GOTREF(__pyx_t_7);
+ PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_6));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
+ 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_GOTREF(__pyx_t_6);
+ __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
+ __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_f_tree));
+ __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_f_tree));
+ __Pyx_GIVEREF(__pyx_t_6);
+ __pyx_cur_scope->__pyx_v_f_tree = ((PyObject*)__pyx_t_6);
+ __pyx_t_6 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":55
+ * 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_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_GOTREF(__pyx_t_7);
+ PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_6));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
+ 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_GOTREF(__pyx_t_6);
+ __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
+ __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_e_tree));
+ __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_e_tree));
+ __Pyx_GIVEREF(__pyx_t_6);
+ __pyx_cur_scope->__pyx_v_e_tree = ((PyObject*)__pyx_t_6);
+ __pyx_t_6 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":56
+ * 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_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));
+ __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_f_tree));
+ __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_e_tree));
+ PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_cur_scope->__pyx_v_e_tree));
+ __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_e_tree));
+ __pyx_r = ((PyObject *)__pyx_t_6);
+ __pyx_t_6 = 0;
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __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_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;}
+ }
+ __pyx_L8_break:;
+ }
- /* "_cdec.pyx":113
- * for k in range(size):
- * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k)
- * if not derivation: break # <<<<<<<<<<<<<<
- * sentence = GetString(derivation._yield).c_str()
- * yield sentence.decode('utf8')
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":58
+ * yield (f_tree, e_tree)
+ * finally:
+ * del f_derivations # <<<<<<<<<<<<<<
+ * del e_derivations
+ *
*/
- __pyx_t_3 = (!(__pyx_cur_scope->__pyx_v_derivation != 0));
- if (__pyx_t_3) {
- goto __pyx_L5_break;
+ /*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_7); __pyx_t_7 = 0;
+ __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 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_f_derivations;
- /* "_cdec.pyx":114
- * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k)
- * if not derivation: break
- * sentence = GetString(derivation._yield).c_str() # <<<<<<<<<<<<<<
- * yield sentence.decode('utf8')
- * 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[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(((PyObject *)__pyx_t_4));
- if (!(likely(PyString_CheckExact(((PyObject *)__pyx_t_4)))||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(((PyObject *)__pyx_t_4))->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_sentence));
- __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_sentence));
- __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
- __pyx_cur_scope->__pyx_v_sentence = ((PyObject*)__pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "_cdec.pyx":115
- * if not derivation: break
- * sentence = GetString(derivation._yield).c_str()
- * yield sentence.decode('utf8') # <<<<<<<<<<<<<<
- * del derivations
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":59
+ * finally:
+ * del f_derivations
+ * del e_derivations # <<<<<<<<<<<<<<
*
+ * def kbest_features(self, size):
*/
- __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_sentence), __pyx_n_s__decode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_5;
- __pyx_t_5 = 0;
- __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
- __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- /* return from generator, yielding value */
- __pyx_generator->resume_label = 1;
- return __pyx_r;
- __pyx_L7_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[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ delete __pyx_cur_scope->__pyx_v_e_derivations;
+ 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;
+ }
+ }
}
- __pyx_L5_break:;
-
- /* "_cdec.pyx":116
- * sentence = GetString(derivation._yield).c_str()
- * yield sentence.decode('utf8')
- * del derivations # <<<<<<<<<<<<<<
- *
- * def intersect(self, Lattice lat):
- */
- delete __pyx_cur_scope->__pyx_v_derivations;
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
__pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("kbest_tree", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_XDECREF(__pyx_t_7);
+ __Pyx_AddTraceback("kbest_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;
}
+static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_10Hypergraph_13intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_lat); /*proto*/
-static PyObject *__pyx_pw_5_cdec_10Hypergraph_13intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_lat) {
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_17kbest_features(PyObject *__pyx_v_self, PyObject *__pyx_v_size); /*proto*/
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_17kbest_features(PyObject *__pyx_v_self, PyObject *__pyx_v_size) {
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[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_10Hypergraph_12intersect(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_lat));
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = NULL;
- __pyx_L0:;
+ __Pyx_RefNannySetupContext("kbest_features (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_10Hypergraph_16kbest_features(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((PyObject *)__pyx_v_size));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "_cdec.pyx":118
- * del derivations
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":61
+ * del e_derivations
*
- * def intersect(self, Lattice lat): # <<<<<<<<<<<<<<
- * assert (self.hg != NULL)
- * hypergraph.Intersect(lat.lattice[0], self.hg)
+ * def kbest_features(self, size): # <<<<<<<<<<<<<<
+ * 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_12intersect(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_16kbest_features(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("intersect", 0);
+ __Pyx_RefNannySetupContext("kbest_features", 0);
+ __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features *)__pyx_ptype_5_cdec___pyx_scope_struct_10_kbest_features->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_10_kbest_features, __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_size = __pyx_v_size;
+ __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_DECREF(__pyx_cur_scope);
+ __Pyx_RefNannyFinishContext();
+ return (PyObject *) gen;
+ }
- /* "_cdec.pyx":119
- *
- * def intersect(self, Lattice lat):
- * assert (self.hg != NULL) # <<<<<<<<<<<<<<
- * hypergraph.Intersect(lat.lattice[0], self.hg)
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.Hypergraph.kbest_features", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+ struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features *)__pyx_generator->closure);
+ PyObject *__pyx_r = NULL;
+ unsigned int __pyx_t_1;
+ long __pyx_t_2;
+ int __pyx_t_3;
+ PyObject *__pyx_t_4 = 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;
+ 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 = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":62
*
+ * def kbest_features(self, size):
+ * 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_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
+ * cdef SparseVector fmap
+ * cdef unsigned k
+ * try: # <<<<<<<<<<<<<<
+ * for k in range(size):
+ * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k)
*/
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!(__pyx_v_self->hg != NULL))) {
- PyErr_SetNone(PyExc_AssertionError);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ /*try:*/ {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":67
+ * 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;}
+ 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
+ * try:
+ * for k in range(size):
+ * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) # <<<<<<<<<<<<<<
+ * if not derivation: break
+ * fmap = SparseVector.__new__(SparseVector)
+ */
+ __pyx_cur_scope->__pyx_v_derivation = __pyx_cur_scope->__pyx_v_derivations->LazyKthBest((__pyx_cur_scope->__pyx_v_self->hg->nodes_.size() - 1), __pyx_cur_scope->__pyx_v_k);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":69
+ * for k in range(size):
+ * 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)
+ */
+ __pyx_t_3 = (!(__pyx_cur_scope->__pyx_v_derivation != 0));
+ if (__pyx_t_3) {
+ goto __pyx_L8_break;
+ goto __pyx_L9;
+ }
+ __pyx_L9:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":70
+ * 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_GOTREF(__pyx_t_4);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L5;}
+ __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_fmap));
+ __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_fmap));
+ __Pyx_GIVEREF(__pyx_t_4);
+ __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
+ * if not derivation: break
+ * fmap = SparseVector.__new__(SparseVector)
+ * fmap.vector = new FastSparseVector[weight_t](derivation._yield) # <<<<<<<<<<<<<<
+ * yield fmap
+ * finally:
+ */
+ __pyx_cur_scope->__pyx_v_fmap->vector = new FastSparseVector<weight_t>(__pyx_cur_scope->__pyx_v_derivation->yield);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":72
+ * fmap = SparseVector.__new__(SparseVector)
+ * fmap.vector = new FastSparseVector[weight_t](derivation._yield)
+ * yield fmap # <<<<<<<<<<<<<<
+ * finally:
+ * del derivations
+ */
+ __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_fmap));
+ __pyx_r = ((PyObject *)__pyx_cur_scope->__pyx_v_fmap);
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __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_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;}
+ }
+ __pyx_L8_break:;
}
- #endif
- /* "_cdec.pyx":120
- * def intersect(self, Lattice lat):
- * assert (self.hg != NULL)
- * hypergraph.Intersect(lat.lattice[0], self.hg) # <<<<<<<<<<<<<<
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":74
+ * yield fmap
+ * finally:
+ * del derivations # <<<<<<<<<<<<<<
*
* def sample(self, unsigned n):
*/
- HG::Intersect((__pyx_v_lat->lattice[0]), __pyx_v_self->hg);
-
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ /*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_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_derivations;
+ 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_AddTraceback("_cdec.Hypergraph.intersect", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_AddTraceback("kbest_features", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_XDECREF(__pyx_r);
+ __pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
__Pyx_RefNannyFinishContext();
- return __pyx_r;
+ return NULL;
}
-static PyObject *__pyx_gb_5_cdec_10Hypergraph_16generator3(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_10Hypergraph_15sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_n); /*proto*/
-static PyObject *__pyx_pw_5_cdec_10Hypergraph_15sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_n) {
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_20sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_n); /*proto*/
+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[0]; __pyx_lineno = 122; __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 = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
@@ -2742,28 +9734,28 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_15sample(PyObject *__pyx_v_self, P
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5_cdec_10Hypergraph_14sample(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((unsigned int)__pyx_v_n));
+ __pyx_r = __pyx_pf_5_cdec_10Hypergraph_19sample(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((unsigned int)__pyx_v_n));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "_cdec.pyx":122
- * hypergraph.Intersect(lat.lattice[0], self.hg)
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":76
+ * del derivations
*
* def sample(self, unsigned n): # <<<<<<<<<<<<<<
- * assert (self.hg != NULL)
* cdef vector[hypergraph.Hypothesis]* hypos = new vector[hypergraph.Hypothesis]()
+ * if self.rng == NULL:
*/
-static PyObject *__pyx_pf_5_cdec_10Hypergraph_14sample(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, unsigned int __pyx_v_n) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample *__pyx_cur_scope;
+static PyObject *__pyx_pf_5_cdec_10Hypergraph_19sample(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, unsigned int __pyx_v_n) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *__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", 0);
- __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample *)__pyx_ptype_5_cdec___pyx_scope_struct_3_sample->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_3_sample, __pyx_empty_tuple, NULL);
+ __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *)__pyx_ptype_5_cdec___pyx_scope_struct_11_sample->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_11_sample, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__Pyx_RefNannyFinishContext();
return NULL;
@@ -2774,7 +9766,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_14sample(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_16generator3, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __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 = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -2792,52 +9784,39 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_14sample(struct __pyx_obj_5_cdec_H
return __pyx_r;
}
-static PyObject *__pyx_gb_5_cdec_10Hypergraph_16generator3(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
- struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample *)__pyx_generator->closure);
+ struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *)__pyx_generator->closure);
PyObject *__pyx_r = NULL;
int __pyx_t_1;
- size_t __pyx_t_2;
- unsigned int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
+ MT19937 *__pyx_t_2;
+ size_t __pyx_t_3;
+ unsigned int __pyx_t_4;
PyObject *__pyx_t_5 = NULL;
+ PyObject *__pyx_t_6 = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("None", 0);
switch (__pyx_generator->resume_label) {
case 0: goto __pyx_L3_first_run;
- case 1: goto __pyx_L7_resume_from_yield;
+ case 1: goto __pyx_L10_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[0]; __pyx_lineno = 122; __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;}
- /* "_cdec.pyx":123
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":77
*
* def sample(self, unsigned n):
- * assert (self.hg != NULL) # <<<<<<<<<<<<<<
- * cdef vector[hypergraph.Hypothesis]* hypos = new vector[hypergraph.Hypothesis]()
- * if self.rng == NULL:
- */
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!(__pyx_cur_scope->__pyx_v_self->hg != NULL))) {
- PyErr_SetNone(PyExc_AssertionError);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
- #endif
-
- /* "_cdec.pyx":124
- * def sample(self, unsigned n):
- * assert (self.hg != NULL)
* 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>();
- /* "_cdec.pyx":125
- * assert (self.hg != NULL)
+ /* "/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()
@@ -2846,111 +9825,2399 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_16generator3(__pyx_GeneratorObject
__pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->rng == NULL);
if (__pyx_t_1) {
- /* "_cdec.pyx":126
+ /* "/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)
- * cdef str sentence
+ * cdef unsigned k
*/
- __pyx_cur_scope->__pyx_v_self->rng = new MT19937();
+ try {__pyx_t_2 = new MT19937();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}}
+ __pyx_cur_scope->__pyx_v_self->rng = __pyx_t_2;
goto __pyx_L4;
}
__pyx_L4:;
- /* "_cdec.pyx":127
+ /* "/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) # <<<<<<<<<<<<<<
- * cdef str sentence
* 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);
- /* "_cdec.pyx":130
- * cdef str sentence
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":82
+ * hypergraph.sample_hypotheses(self.hg[0], n, self.rng, hypos)
* cdef unsigned k
- * for k in range(hypos.size()): # <<<<<<<<<<<<<<
- * sentence = GetString(hypos[0][k].words).c_str()
- * yield sentence.decode('utf8')
+ * try: # <<<<<<<<<<<<<<
+ * for k in range(hypos.size()):
+ * yield unicode(GetString(hypos[0][k].words).c_str(), 'utf8')
*/
- __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;
+ /*try:*/ {
- /* "_cdec.pyx":131
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":83
* cdef unsigned k
- * for k in range(hypos.size()):
- * sentence = GetString(hypos[0][k].words).c_str() # <<<<<<<<<<<<<<
- * yield sentence.decode('utf8')
- * del hypos
+ * try:
+ * for k in range(hypos.size()): # <<<<<<<<<<<<<<
+ * yield unicode(GetString(hypos[0][k].words).c_str(), 'utf8')
+ * finally:
*/
- __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[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(((PyObject *)__pyx_t_4));
- if (!(likely(PyString_CheckExact(((PyObject *)__pyx_t_4)))||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(((PyObject *)__pyx_t_4))->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_sentence));
- __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_sentence));
- __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
- __pyx_cur_scope->__pyx_v_sentence = ((PyObject*)__pyx_t_4);
+ __pyx_t_3 = __pyx_cur_scope->__pyx_v_hypos->size();
+ for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
+ __pyx_cur_scope->__pyx_v_k = __pyx_t_4;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":84
+ * try:
+ * 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_INCREF(((PyObject *)__pyx_n_s__utf8));
+ PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_n_s__utf8));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
+ __pyx_t_5 = 0;
+ __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L6;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+ __pyx_r = __pyx_t_5;
+ __pyx_t_5 = 0;
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 1;
+ return __pyx_r;
+ __pyx_L10_resume_from_yield:;
+ __pyx_t_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;}
+ }
+ }
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":86
+ * yield unicode(GetString(hypos[0][k].words).c_str(), 'utf8')
+ * finally:
+ * del hypos # <<<<<<<<<<<<<<
+ *
+ * def intersect(self, Lattice lat):
+ */
+ /*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 = 4;
+ __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
+ __pyx_exc_lineno = __pyx_lineno;
+ goto __pyx_L7;
+ }
+ __pyx_L7:;
+ delete __pyx_cur_scope->__pyx_v_hypos;
+ 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_5);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_AddTraceback("sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_r);
+ __pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+}
+
+/* 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) {
+ 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));
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":88
+ * del hypos
+ *
+ * def intersect(self, Lattice lat): # <<<<<<<<<<<<<<
+ * return hypergraph.Intersect(lat.lattice[0], self.hg)
+ *
+ */
+
+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) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("intersect", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":89
+ *
+ * def intersect(self, Lattice lat):
+ * 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;
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.Hypergraph.intersect", __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_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) {
+ PyObject *__pyx_v_beam_alpha = 0;
+ PyObject *__pyx_v_density = 0;
+ PyObject *__pyx_v_kwargs = 0;
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("prune (wrapper)", 0);
+ __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
+ __Pyx_GOTREF(__pyx_v_kwargs);
+ {
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__beam_alpha,&__pyx_n_s__density,0};
+ PyObject* values[2] = {0,0};
+ values[0] = ((PyObject *)__pyx_int_0);
+ values[1] = ((PyObject *)__pyx_int_0);
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args;
+ const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+ switch (pos_args) {
+ case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ kw_args = PyDict_Size(__pyx_kwds);
+ switch (pos_args) {
+ case 0:
+ if (kw_args > 0) {
+ PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__beam_alpha);
+ if (value) { values[0] = value; kw_args--; }
+ }
+ case 1:
+ if (kw_args > 0) {
+ PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__density);
+ if (value) { values[1] = value; kw_args--; }
+ }
+ }
+ 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;}
+ }
+ } else {
+ switch (PyTuple_GET_SIZE(__pyx_args)) {
+ case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ }
+ __pyx_v_beam_alpha = values[0];
+ __pyx_v_density = values[1];
+ }
+ 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_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_XDECREF(__pyx_v_kwargs);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":91
+ * 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:
+ */
+
+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) {
+ std::vector<bool> *__pyx_v_preserve_mask;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ int __pyx_t_1;
+ double __pyx_t_2;
+ double __pyx_t_3;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ 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):
+ * 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):
+ * 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;}
+ if (__pyx_t_1) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":94
+ * 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
+ * self.hg.PruneInsideOutside(beam_alpha, density, preserve_mask, False, 1, False)
+ */
+ __pyx_v_preserve_mask = new std::vector<bool>(__pyx_v_self->hg->edges_.size());
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":95
+ * 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 # <<<<<<<<<<<<<<
+ * self.hg.PruneInsideOutside(beam_alpha, density, preserve_mask, False, 1, False)
+ * if preserve_mask:
+ */
+ ((__pyx_v_preserve_mask[0])[CompoundSplit::GetFullWordEdgeIndex((__pyx_v_self->hg[0]))]) = 1;
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":96
+ * 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_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
+ * 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_1 = (__pyx_v_preserve_mask != 0);
+ if (__pyx_t_1) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":98
+ * self.hg.PruneInsideOutside(beam_alpha, density, preserve_mask, False, 1, False)
+ * if preserve_mask:
+ * del preserve_mask # <<<<<<<<<<<<<<
+ *
+ * def lattice(self): # TODO direct hg -> lattice conversion in cdec
+ */
+ delete __pyx_v_preserve_mask;
+ goto __pyx_L4;
+ }
+ __pyx_L4:;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.Hypergraph.prune", __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_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) {
+ 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_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":100
+ * 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))
+ */
+
+static PyObject *__pyx_pf_5_cdec_10Hypergraph_26lattice(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) {
+ PyObject *__pyx_v_plf = 0;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("lattice", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":101
+ *
+ * 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))
+ *
+ */
+ __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_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_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()
+ * return Lattice(eval(plf)) # <<<<<<<<<<<<<<
+ *
+ * def reweight(self, weights):
+ */
+ __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_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_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 (((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;}
+ }
+ __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_GOTREF(__pyx_t_3);
+ __Pyx_INCREF(((PyObject *)__pyx_v_plf));
+ PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_plf));
+ __Pyx_GIVEREF(((PyObject *)__pyx_v_plf));
+ PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_t_1));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+ PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_t_2));
+ __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_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_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_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 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_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("_cdec.Hypergraph.lattice", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_plf);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* 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) {
+ 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_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":104
+ * return Lattice(eval(plf))
+ *
+ * def reweight(self, weights): # <<<<<<<<<<<<<<
+ * 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) {
+ 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("reweight", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":105
+ *
+ * def reweight(self, weights):
+ * if isinstance(weights, SparseVector): # <<<<<<<<<<<<<<
+ * self.hg.Reweight((<SparseVector> weights).vector[0])
+ * elif isinstance(weights, DenseVector):
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector));
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_weights, __pyx_t_1);
+ __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):
+ * if isinstance(weights, SparseVector):
+ * self.hg.Reweight((<SparseVector> weights).vector[0]) # <<<<<<<<<<<<<<
+ * elif isinstance(weights, DenseVector):
+ * self.hg.Reweight((<DenseVector> weights).vector[0])
+ */
+ __pyx_v_self->hg->Reweight((((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_weights)->vector[0]));
+ goto __pyx_L3;
+ }
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":107
+ * if isinstance(weights, SparseVector):
+ * self.hg.Reweight((<SparseVector> weights).vector[0])
+ * elif isinstance(weights, DenseVector): # <<<<<<<<<<<<<<
+ * self.hg.Reweight((<DenseVector> weights).vector[0])
+ * else:
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_DenseVector));
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_weights, __pyx_t_1);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ if (__pyx_t_2) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":108
+ * self.hg.Reweight((<SparseVector> weights).vector[0])
+ * elif isinstance(weights, DenseVector):
+ * self.hg.Reweight((<DenseVector> weights).vector[0]) # <<<<<<<<<<<<<<
+ * else:
+ * raise TypeError('cannot reweight hypergraph with %s' % type(weights))
+ */
+ __pyx_v_self->hg->Reweight((((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_weights)->vector[0]));
+ goto __pyx_L3;
+ }
+ /*else*/ {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":110
+ * 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_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_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_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_L3:;
+
+ __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.reweight", __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_10Hypergraph_5edges_2generator8(__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*/
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_5edges_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_10Hypergraph_5edges___get__(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/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()):
+ */
+
+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;
+ 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);
+ 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_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_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.edges.__get__", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator8(__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);
+ PyObject *__pyx_r = NULL;
+ size_t __pyx_t_1;
+ unsigned int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ PyObject *__pyx_t_4 = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("None", 0);
+ switch (__pyx_generator->resume_label) {
+ case 0: goto __pyx_L3_first_run;
+ case 1: goto __pyx_L6_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 = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":115
+ * def __get__(self):
+ * cdef unsigned i
+ * for i in range(self.hg.edges_.size()): # <<<<<<<<<<<<<<
+ * yield HypergraphEdge().init(self.hg, i)
+ *
+ */
+ __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->hg->edges_.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/hypergraph.pxi":116
+ * 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_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_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_r = __pyx_t_4;
__pyx_t_4 = 0;
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 1;
+ return __pyx_r;
+ __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;}
+ }
+ PyErr_SetNone(PyExc_StopIteration);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_AddTraceback("__get__", __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;
+}
+static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator9(__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*/
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_5nodes_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_10Hypergraph_5nodes___get__(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
- /* "_cdec.pyx":132
- * for k in range(hypos.size()):
- * sentence = GetString(hypos[0][k].words).c_str()
- * yield sentence.decode('utf8') # <<<<<<<<<<<<<<
- * del hypos
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":119
*
+ * property nodes:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * for i in range(self.hg.nodes_.size()):
*/
- __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_sentence), __pyx_n_s__decode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+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;
+ 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);
+ 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_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_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.nodes.__get__", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator9(__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);
+ PyObject *__pyx_r = NULL;
+ size_t __pyx_t_1;
+ unsigned int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ PyObject *__pyx_t_4 = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("None", 0);
+ switch (__pyx_generator->resume_label) {
+ case 0: goto __pyx_L3_first_run;
+ case 1: goto __pyx_L6_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 = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":121
+ * def __get__(self):
+ * cdef unsigned i
+ * for i in range(self.hg.nodes_.size()): # <<<<<<<<<<<<<<
+ * yield HypergraphNode().init(self.hg, i)
+ *
+ */
+ __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->hg->nodes_.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/hypergraph.pxi":122
+ * 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_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_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_5;
- __pyx_t_5 = 0;
- __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
- __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_r = __pyx_t_4;
+ __pyx_t_4 = 0;
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
/* return from generator, yielding value */
__pyx_generator->resume_label = 1;
return __pyx_r;
- __pyx_L7_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[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __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;}
+ }
+ PyErr_SetNone(PyExc_StopIteration);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_AddTraceback("__get__", __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_4goal_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_4goal_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_10Hypergraph_4goal___get__(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":125
+ *
+ * property goal:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * return HypergraphNode().init(self.hg, self.hg.GoalNode())
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_10Hypergraph_4goal___get__(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("__get__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":126
+ * property goal:
+ * def __get__(self):
+ * return HypergraphNode().init(self.hg, self.hg.GoalNode()) # <<<<<<<<<<<<<<
+ *
+ * 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_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_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(__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.Hypergraph.goal.__get__", __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_6npaths_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_10Hypergraph_6npaths_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_10Hypergraph_6npaths___get__(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":129
+ *
+ * property npaths:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * return self.hg.NumberOfPaths()
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_10Hypergraph_6npaths___get__(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__get__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":130
+ * property npaths:
+ * def __get__(self):
+ * return self.hg.NumberOfPaths() # <<<<<<<<<<<<<<
+ *
+ * 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_GOTREF(__pyx_t_1);
+ __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_AddTraceback("_cdec.Hypergraph.npaths.__get__", __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_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) {
+ 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_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":132
+ * return self.hg.NumberOfPaths()
+ *
+ * def inside_outside(self): # <<<<<<<<<<<<<<
+ * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]()
+ * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result)
+ */
+
+static PyObject *__pyx_pf_5_cdec_10Hypergraph_30inside_outside(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) {
+ FastSparseVector<prob_t> *__pyx_v_result;
+ prob_t __pyx_v_z;
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_vector = 0;
+ FastSparseVector<prob_t>::const_iterator *__pyx_v_it;
+ CYTHON_UNUSED unsigned int __pyx_v_i;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ size_t __pyx_t_2;
+ unsigned int __pyx_t_3;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("inside_outside", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":133
+ *
+ * def inside_outside(self):
+ * 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):
+ * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]()
+ * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) # <<<<<<<<<<<<<<
+ * result[0] /= z
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector)
+ */
+ __pyx_v_z = InsideOutside<prob_t, EdgeProb, SparseVector<prob_t>, EdgeFeaturesAndProbWeightFunction>((__pyx_v_self->hg[0]), __pyx_v_result);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":135
+ * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]()
+ * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result)
+ * result[0] /= z # <<<<<<<<<<<<<<
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector)
+ * vector.vector = new FastSparseVector[double]()
+ */
+ (__pyx_v_result[0]) /= __pyx_v_z;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":136
+ * cdef 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_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":137
+ * result[0] /= z
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector)
+ * vector.vector = new FastSparseVector[double]() # <<<<<<<<<<<<<<
+ * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False)
+ * cdef unsigned i
+ */
+ __pyx_v_vector->vector = new FastSparseVector<double>();
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":138
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector)
+ * vector.vector = new FastSparseVector[double]()
+ * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False) # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * for i in range(result.size()):
+ */
+ __pyx_v_it = new FastSparseVector<prob_t>::const_iterator((__pyx_v_result[0]), 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":140
+ * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False)
+ * cdef unsigned i
+ * for i in range(result.size()): # <<<<<<<<<<<<<<
+ * vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second))
+ * pinc(it[0]) # ++it
+ */
+ __pyx_t_2 = __pyx_v_result->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/hypergraph.pxi":141
+ * cdef unsigned i
+ * for i in range(result.size()):
+ * vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second)) # <<<<<<<<<<<<<<
+ * pinc(it[0]) # ++it
+ * del it
+ */
+ __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
+ * for i in range(result.size()):
+ * vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second))
+ * pinc(it[0]) # ++it # <<<<<<<<<<<<<<
+ * del it
+ * del result
+ */
+ (++(__pyx_v_it[0]));
+ }
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":143
+ * vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second))
+ * pinc(it[0]) # ++it
+ * del it # <<<<<<<<<<<<<<
+ * del result
+ * return vector
+ */
+ delete __pyx_v_it;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":144
+ * pinc(it[0]) # ++it
+ * del it
+ * del result # <<<<<<<<<<<<<<
+ * return vector
+ *
+ */
+ delete __pyx_v_result;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":145
+ * del it
+ * del result
+ * return vector # <<<<<<<<<<<<<<
+ *
+ * cdef class HypergraphEdge:
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_vector));
+ __pyx_r = ((PyObject *)__pyx_v_vector);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.Hypergraph.inside_outside", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_vector);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":152
+ * cdef public TRule trule
+ *
+ * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): # <<<<<<<<<<<<<<
+ * self.hg = hg
+ * self.edge = &hg.edges_[i]
+ */
+
+static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self, Hypergraph *__pyx_v_hg, unsigned int __pyx_v_i) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("init", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":153
+ *
+ * cdef init(self, hypergraph.Hypergraph* hg, unsigned i):
+ * self.hg = hg # <<<<<<<<<<<<<<
+ * self.edge = &hg.edges_[i]
+ * self.trule = TRule.__new__(TRule)
+ */
+ __pyx_v_self->hg = __pyx_v_hg;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":154
+ * cdef init(self, hypergraph.Hypergraph* hg, unsigned i):
+ * self.hg = hg
+ * self.edge = &hg.edges_[i] # <<<<<<<<<<<<<<
+ * self.trule = TRule.__new__(TRule)
+ * self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_)
+ */
+ __pyx_v_self->edge = (&(__pyx_v_hg->edges_[__pyx_v_i]));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":155
+ * 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_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GIVEREF(__pyx_t_1);
+ __Pyx_GOTREF(__pyx_v_self->trule);
+ __Pyx_DECREF(((PyObject *)__pyx_v_self->trule));
+ __pyx_v_self->trule = ((struct __pyx_obj_5_cdec_TRule *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":156
+ * self.edge = &hg.edges_[i]
+ * self.trule = TRule.__new__(TRule)
+ * self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_) # <<<<<<<<<<<<<<
+ * return self
+ *
+ */
+ __pyx_v_self->trule->rule = new boost::shared_ptr<TRule>(__pyx_v_self->edge->rule_);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":157
+ * self.trule = TRule.__new__(TRule)
+ * self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_)
+ * return self # <<<<<<<<<<<<<<
+ *
+ * def __len__(self):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_self));
+ __pyx_r = ((PyObject *)__pyx_v_self);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.HypergraphEdge.init", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = 0;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static Py_ssize_t __pyx_pw_5_cdec_14HypergraphEdge_1__len__(PyObject *__pyx_v_self); /*proto*/
+static Py_ssize_t __pyx_pw_5_cdec_14HypergraphEdge_1__len__(PyObject *__pyx_v_self) {
+ Py_ssize_t __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_14HypergraphEdge___len__(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":159
+ * return self
+ *
+ * def __len__(self): # <<<<<<<<<<<<<<
+ * return self.edge.tail_nodes_.size()
+ *
+ */
+
+static Py_ssize_t __pyx_pf_5_cdec_14HypergraphEdge___len__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self) {
+ Py_ssize_t __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__len__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":160
+ *
+ * def __len__(self):
+ * return self.edge.tail_nodes_.size() # <<<<<<<<<<<<<<
+ *
+ * property head_node:
+ */
+ __pyx_r = __pyx_v_self->edge->tail_nodes_.size();
+ goto __pyx_L0;
+
+ __pyx_r = 0;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_9head_node_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_9head_node_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_14HypergraphEdge_9head_node___get__(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":163
+ *
+ * property head_node:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * return HypergraphNode().init(self.hg, self.edge.head_node_)
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_9head_node___get__(struct __pyx_obj_5_cdec_HypergraphEdge *__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":164
+ * property head_node:
+ * def __get__(self):
+ * return HypergraphNode().init(self.hg, self.edge.head_node_) # <<<<<<<<<<<<<<
+ *
+ * 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_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_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(__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.HypergraphEdge.head_node.__get__", __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_14HypergraphEdge_10tail_nodes_2generator10(__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*/
+static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_10tail_nodes_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_14HypergraphEdge_10tail_nodes___get__(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":167
+ *
+ * property tail_nodes:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * for i in range(self.edge.tail_nodes_.size()):
+ */
+
+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;
+ 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);
+ 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_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_DECREF(__pyx_cur_scope);
+ __Pyx_RefNannyFinishContext();
+ return (PyObject *) gen;
}
- /* "_cdec.pyx":133
- * sentence = GetString(hypos[0][k].words).c_str()
- * yield sentence.decode('utf8')
- * del hypos # <<<<<<<<<<<<<<
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.HypergraphEdge.tail_nodes.__get__", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator10(__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);
+ PyObject *__pyx_r = NULL;
+ unsigned int __pyx_t_1;
+ unsigned int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ PyObject *__pyx_t_4 = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("None", 0);
+ switch (__pyx_generator->resume_label) {
+ case 0: goto __pyx_L3_first_run;
+ case 1: goto __pyx_L6_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 = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":169
+ * def __get__(self):
+ * cdef unsigned i
+ * for i in range(self.edge.tail_nodes_.size()): # <<<<<<<<<<<<<<
+ * yield HypergraphNode().init(self.hg, self.edge.tail_nodes_[i])
+ *
+ */
+ __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->edge->tail_nodes_.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/hypergraph.pxi":170
+ * cdef unsigned i
+ * for i in range(self.edge.tail_nodes_.size()):
+ * yield HypergraphNode().init(self.hg, self.edge.tail_nodes_[i]) # <<<<<<<<<<<<<<
*
- * # TODO: get feature expectations, get partition function ("inside" score)
+ * property span:
*/
- delete __pyx_cur_scope->__pyx_v_hypos;
+ __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_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_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_r = __pyx_t_4;
+ __pyx_t_4 = 0;
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 1;
+ return __pyx_r;
+ __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;}
+ }
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
__pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("sample", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("__get__", __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 int __pyx_pw_5_cdec_7Lattice_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pw_5_cdec_7Lattice_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_plf_tuple = 0;
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__plf_tuple,0};
+static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_4span_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_4span_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_14HypergraphEdge_4span___get__(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":173
+ *
+ * property span:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * return (self.edge.i_, self.edge.j_)
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4span___get__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = 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":174
+ * property span:
+ * def __get__(self):
+ * return (self.edge.i_, self.edge.j_) # <<<<<<<<<<<<<<
+ *
+ * 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_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_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_GOTREF(__pyx_t_3);
+ PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
+ __Pyx_GIVEREF(__pyx_t_1);
+ PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
+ __Pyx_GIVEREF(__pyx_t_2);
+ __pyx_t_1 = 0;
+ __pyx_t_2 = 0;
+ __pyx_r = ((PyObject *)__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_2);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("_cdec.HypergraphEdge.span.__get__", __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_14HypergraphEdge_14feature_values_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_14feature_values_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_14HypergraphEdge_14feature_values___get__(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":177
+ *
+ * property feature_values:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector)
+ * vector.vector = new FastSparseVector[double](self.edge.feature_values_)
+ */
+
+static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_14feature_values___get__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self) {
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_vector = 0;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__get__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":178
+ * 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_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":179
+ * def __get__(self):
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector)
+ * vector.vector = new FastSparseVector[double](self.edge.feature_values_) # <<<<<<<<<<<<<<
+ * return vector
+ *
+ */
+ __pyx_v_vector->vector = new FastSparseVector<double>(__pyx_v_self->edge->feature_values_);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":180
+ * cdef SparseVector vector = SparseVector.__new__(SparseVector)
+ * vector.vector = new FastSparseVector[double](self.edge.feature_values_)
+ * return vector # <<<<<<<<<<<<<<
+ *
+ * property prob:
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_vector));
+ __pyx_r = ((PyObject *)__pyx_v_vector);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.HypergraphEdge.feature_values.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_vector);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_4prob_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_4prob_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_14HypergraphEdge_4prob___get__(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":183
+ *
+ * property prob:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * return self.edge.edge_prob_.as_float()
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4prob___get__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__get__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":184
+ * property prob:
+ * def __get__(self):
+ * return self.edge.edge_prob_.as_float() # <<<<<<<<<<<<<<
+ *
+ * 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_GOTREF(__pyx_t_1);
+ __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_AddTraceback("_cdec.HypergraphEdge.prob.__get__", __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_14HypergraphEdge_3__richcmp__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op); /*proto*/
+static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_3__richcmp__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_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;}
+ __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:;
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":186
+ * return self.edge.edge_prob_.as_float()
+ *
+ * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op): # <<<<<<<<<<<<<<
+ * if op == 2: # ==
+ * return x.edge == y.edge
+ */
+
+static PyObject *__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) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_t_2;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__richcmp__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":189
+ * if op == 2: # ==
+ * return x.edge == y.edge
+ * elif op == 3: # != # <<<<<<<<<<<<<<
+ * return not (x == y)
+ * raise NotImplemented('comparison not implemented for HypergraphEdge')
+ */
+ switch (__pyx_v_op) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":187
+ *
+ * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op):
+ * if op == 2: # == # <<<<<<<<<<<<<<
+ * return x.edge == y.edge
+ * elif op == 3: # !=
+ */
+ case 2:
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":188
+ * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op):
+ * if op == 2: # ==
+ * return x.edge == y.edge # <<<<<<<<<<<<<<
+ * elif op == 3: # !=
+ * 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_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
+ * if op == 2: # ==
+ * return x.edge == y.edge
+ * elif op == 3: # != # <<<<<<<<<<<<<<
+ * return not (x == y)
+ * raise NotImplemented('comparison not implemented for HypergraphEdge')
+ */
+ case 3:
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":190
+ * return x.edge == y.edge
+ * elif op == 3: # !=
+ * return not (x == y) # <<<<<<<<<<<<<<
+ * raise NotImplemented('comparison not implemented for HypergraphEdge')
+ *
+ */
+ __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_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_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":191
+ * 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_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_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.HypergraphEdge.__richcmp__", __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_14HypergraphEdge_5trule_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_5trule_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_14HypergraphEdge_5trule___get__(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":150
+ * cdef hypergraph.Hypergraph* hg
+ * cdef hypergraph.HypergraphEdge* edge
+ * cdef public TRule trule # <<<<<<<<<<<<<<
+ *
+ * cdef init(self, hypergraph.Hypergraph* hg, unsigned i):
+ */
+
+static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_5trule___get__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__", 0);
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_self->trule));
+ __pyx_r = ((PyObject *)__pyx_v_self->trule);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_14HypergraphEdge_5trule_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pw_5_cdec_14HypergraphEdge_5trule_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
int __pyx_r;
__Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+ __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_14HypergraphEdge_5trule_2__set__(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_self), ((PyObject *)__pyx_v_value));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static int __pyx_pf_5_cdec_14HypergraphEdge_5trule_2__set__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self, PyObject *__pyx_v_value) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ int __pyx_lineno = 0;
+ 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;}
+ __Pyx_INCREF(__pyx_v_value);
+ __Pyx_GIVEREF(__pyx_v_value);
+ __Pyx_GOTREF(__pyx_v_self->trule);
+ __Pyx_DECREF(((PyObject *)__pyx_v_self->trule));
+ __pyx_v_self->trule = ((struct __pyx_obj_5_cdec_TRule *)__pyx_v_value);
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.HypergraphEdge.trule.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_14HypergraphEdge_5trule_5__del__(PyObject *__pyx_v_self); /*proto*/
+static int __pyx_pw_5_cdec_14HypergraphEdge_5trule_5__del__(PyObject *__pyx_v_self) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_14HypergraphEdge_5trule_4__del__(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static int __pyx_pf_5_cdec_14HypergraphEdge_5trule_4__del__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__del__", 0);
+ __Pyx_INCREF(Py_None);
+ __Pyx_GIVEREF(Py_None);
+ __Pyx_GOTREF(__pyx_v_self->trule);
+ __Pyx_DECREF(((PyObject *)__pyx_v_self->trule));
+ __pyx_v_self->trule = ((struct __pyx_obj_5_cdec_TRule *)Py_None);
+
+ __pyx_r = 0;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":197
+ * cdef hypergraph.HypergraphNode* node
+ *
+ * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): # <<<<<<<<<<<<<<
+ * self.hg = hg
+ * self.node = &hg.nodes_[i]
+ */
+
+static PyObject *__pyx_f_5_cdec_14HypergraphNode_init(struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_self, Hypergraph *__pyx_v_hg, unsigned int __pyx_v_i) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("init", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":198
+ *
+ * cdef init(self, hypergraph.Hypergraph* hg, unsigned i):
+ * self.hg = hg # <<<<<<<<<<<<<<
+ * self.node = &hg.nodes_[i]
+ * return self
+ */
+ __pyx_v_self->hg = __pyx_v_hg;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":199
+ * cdef init(self, hypergraph.Hypergraph* hg, unsigned i):
+ * self.hg = hg
+ * self.node = &hg.nodes_[i] # <<<<<<<<<<<<<<
+ * return self
+ *
+ */
+ __pyx_v_self->node = (&(__pyx_v_hg->nodes_[__pyx_v_i]));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":200
+ * self.hg = hg
+ * self.node = &hg.nodes_[i]
+ * return self # <<<<<<<<<<<<<<
+ *
+ * property in_edges:
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_self));
+ __pyx_r = ((PyObject *)__pyx_v_self);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator11(__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*/
+static PyObject *__pyx_pw_5_cdec_14HypergraphNode_8in_edges_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_14HypergraphNode_8in_edges___get__(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":203
+ *
+ * property in_edges:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * for i in range(self.node.in_edges_.size()):
+ */
+
+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;
+ 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);
+ 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_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_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.HypergraphNode.in_edges.__get__", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator11(__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);
+ PyObject *__pyx_r = NULL;
+ size_t __pyx_t_1;
+ unsigned int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ PyObject *__pyx_t_4 = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("None", 0);
+ switch (__pyx_generator->resume_label) {
+ case 0: goto __pyx_L3_first_run;
+ case 1: goto __pyx_L6_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 = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":205
+ * def __get__(self):
+ * cdef unsigned i
+ * for i in range(self.node.in_edges_.size()): # <<<<<<<<<<<<<<
+ * yield HypergraphEdge().init(self.hg, self.node.in_edges_[i])
+ *
+ */
+ __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->node->in_edges_.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/hypergraph.pxi":206
+ * 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_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_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_r = __pyx_t_4;
+ __pyx_t_4 = 0;
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 1;
+ return __pyx_r;
+ __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;}
+ }
+ PyErr_SetNone(PyExc_StopIteration);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_AddTraceback("__get__", __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;
+}
+static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator12(__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*/
+static PyObject *__pyx_pw_5_cdec_14HypergraphNode_9out_edges_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_14HypergraphNode_9out_edges___get__(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":209
+ *
+ * property out_edges:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * for i in range(self.node.out_edges_.size()):
+ */
+
+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;
+ 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);
+ 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_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_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.HypergraphNode.out_edges.__get__", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator12(__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);
+ PyObject *__pyx_r = NULL;
+ size_t __pyx_t_1;
+ unsigned int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ PyObject *__pyx_t_4 = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("None", 0);
+ switch (__pyx_generator->resume_label) {
+ case 0: goto __pyx_L3_first_run;
+ case 1: goto __pyx_L6_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 = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":211
+ * def __get__(self):
+ * cdef unsigned i
+ * for i in range(self.node.out_edges_.size()): # <<<<<<<<<<<<<<
+ * yield HypergraphEdge().init(self.hg, self.node.out_edges_[i])
+ *
+ */
+ __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->node->out_edges_.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/hypergraph.pxi":212
+ * 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_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_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_r = __pyx_t_4;
+ __pyx_t_4 = 0;
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 1;
+ return __pyx_r;
+ __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;}
+ }
+ PyErr_SetNone(PyExc_StopIteration);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_AddTraceback("__get__", __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_14HypergraphNode_4span_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_14HypergraphNode_4span_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_14HypergraphNode_4span___get__(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":215
+ *
+ * property span:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * return next(self.in_edges).span
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_14HypergraphNode_4span___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":216
+ * property span:
+ * def __get__(self):
+ * return next(self.in_edges).span # <<<<<<<<<<<<<<
+ *
+ * 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_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_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_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(__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.HypergraphNode.span.__get__", __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_14HypergraphNode_3cat_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_14HypergraphNode_3cat_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_14HypergraphNode_3cat___get__(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":219
+ *
+ * property cat:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * if self.node.cat_:
+ * return TDConvert(-self.node.cat_)
+ */
+
+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;
+ 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
+ * property cat:
+ * def __get__(self):
+ * if self.node.cat_: # <<<<<<<<<<<<<<
+ * return TDConvert(-self.node.cat_)
+ *
+ */
+ if (__pyx_v_self->node->cat_) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":221
+ * def __get__(self):
+ * if self.node.cat_:
+ * return TDConvert(-self.node.cat_) # <<<<<<<<<<<<<<
+ *
+ * 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_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_r = ((PyObject *)__pyx_t_1);
+ __pyx_t_1 = 0;
+ goto __pyx_L0;
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.HypergraphNode.cat.__get__", __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_14HypergraphNode_1__richcmp__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op); /*proto*/
+static PyObject *__pyx_pw_5_cdec_14HypergraphNode_1__richcmp__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_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;}
+ __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:;
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":223
+ * return TDConvert(-self.node.cat_)
+ *
+ * def __richcmp__(HypergraphNode x, HypergraphNode y, int op): # <<<<<<<<<<<<<<
+ * if op == 2: # ==
+ * return x.node == y.node
+ */
+
+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) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_t_2;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__richcmp__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":226
+ * if op == 2: # ==
+ * return x.node == y.node
+ * elif op == 3: # != # <<<<<<<<<<<<<<
+ * return not (x == y)
+ * raise NotImplemented('comparison not implemented for HypergraphNode')
+ */
+ switch (__pyx_v_op) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":224
+ *
+ * def __richcmp__(HypergraphNode x, HypergraphNode y, int op):
+ * if op == 2: # == # <<<<<<<<<<<<<<
+ * return x.node == y.node
+ * elif op == 3: # !=
+ */
+ case 2:
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":225
+ * def __richcmp__(HypergraphNode x, HypergraphNode y, int op):
+ * if op == 2: # ==
+ * return x.node == y.node # <<<<<<<<<<<<<<
+ * elif op == 3: # !=
+ * 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_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
+ * if op == 2: # ==
+ * return x.node == y.node
+ * elif op == 3: # != # <<<<<<<<<<<<<<
+ * return not (x == y)
+ * raise NotImplemented('comparison not implemented for HypergraphNode')
+ */
+ case 3:
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":227
+ * 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_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_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":228
+ * 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_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_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.HypergraphNode.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* 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);
{
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__inp,0};
PyObject* values[1] = {0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
@@ -2963,30 +12230,513 @@ static int __pyx_pw_5_cdec_7Lattice_1__init__(PyObject *__pyx_v_self, PyObject *
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
- values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__plf_tuple);
- if (likely(values[0])) kw_args--;
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__inp)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __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[4]; __pyx_lineno = 6; __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_plf_tuple = ((PyObject*)values[0]);
+ __pyx_v_inp = values[0];
}
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[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L3_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_L3_error:;
+ __Pyx_AddTraceback("_cdec.Lattice.__cinit__", __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_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":6
+ * cdef lattice.Lattice* lattice
+ *
+ * def __cinit__(self, inp): # <<<<<<<<<<<<<<
+ * if isinstance(inp, tuple):
+ * self.lattice = new lattice.Lattice(len(inp))
+ */
+
+static int __pyx_pf_5_cdec_7Lattice___cinit__(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;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_t_2;
+ Py_ssize_t __pyx_t_3;
+ PyObject *__pyx_t_4 = NULL;
+ PyObject *(*__pyx_t_5)(PyObject *);
+ PyObject *__pyx_t_6 = NULL;
+ int __pyx_t_7;
+ char *__pyx_t_8;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__cinit__", 0);
+ __Pyx_INCREF(__pyx_v_inp);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":7
+ *
+ * def __cinit__(self, inp):
+ * if isinstance(inp, tuple): # <<<<<<<<<<<<<<
+ * self.lattice = new lattice.Lattice(len(inp))
+ * for i, arcs in enumerate(inp):
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)(&PyTuple_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) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":8
+ * def __cinit__(self, inp):
+ * if isinstance(inp, tuple):
+ * self.lattice = new lattice.Lattice(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);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":9
+ * if isinstance(inp, tuple):
+ * self.lattice = new lattice.Lattice(len(inp))
+ * for i, arcs in enumerate(inp): # <<<<<<<<<<<<<<
+ * self[i] = arcs
+ * else:
+ */
+ __Pyx_INCREF(__pyx_int_0);
+ __pyx_t_1 = __pyx_int_0;
+ if (PyList_CheckExact(__pyx_v_inp) || PyTuple_CheckExact(__pyx_v_inp)) {
+ __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_GOTREF(__pyx_t_4);
+ __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
+ }
+ for (;;) {
+ if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_4)) {
+ if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_4)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++;
+ #else
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_4)) {
+ if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++;
+ #else
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_6 = __pyx_t_5(__pyx_t_4);
+ if (unlikely(!__pyx_t_6)) {
+ 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;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_6);
+ }
+ __Pyx_XDECREF(__pyx_v_arcs);
+ __pyx_v_arcs = __pyx_t_6;
+ __pyx_t_6 = 0;
+ __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_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))
+ * for i, arcs in enumerate(inp):
+ * self[i] = arcs # <<<<<<<<<<<<<<
+ * else:
+ * if isinstance(inp, unicode):
+ */
+ 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;}
+ }
+ __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
+ * self[i] = arcs
+ * 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) {
+
+ /* "/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_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)
+ *
+ */
+ __pyx_v_self->lattice = new Lattice();
+
+ /* "/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) # <<<<<<<<<<<<<<
+ *
+ * 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_L3:;
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_AddTraceback("_cdec.Lattice.__cinit__", __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) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+ __pyx_pf_5_cdec_7Lattice_2__dealloc__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":19
+ * lattice.ConvertTextToLattice(string(<char *>inp), self.lattice)
+ *
+ * def __dealloc__(self): # <<<<<<<<<<<<<<
+ * del self.lattice
+ *
+ */
+
+static void __pyx_pf_5_cdec_7Lattice_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":20
+ *
+ * def __dealloc__(self):
+ * del self.lattice # <<<<<<<<<<<<<<
+ *
+ * def __getitem__(self, int index):
+ */
+ delete __pyx_v_self->lattice;
+
+ __Pyx_RefNannyFinishContext();
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_7Lattice_5__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index); /*proto*/
+static PyObject *__pyx_pw_5_cdec_7Lattice_5__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index) {
+ int __pyx_v_index;
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
+ assert(__pyx_arg_index); {
+ __pyx_v_index = __Pyx_PyInt_AsInt(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("_cdec.Lattice.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __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_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":22
+ * del self.lattice
+ *
+ * def __getitem__(self, int index): # <<<<<<<<<<<<<<
+ * if not 0 <= index < len(self):
+ * raise IndexError('lattice index out of range')
+ */
+
+static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index) {
+ PyObject *__pyx_v_arcs = NULL;
+ std::vector<LatticeArc> __pyx_v_arc_vector;
+ LatticeArc *__pyx_v_arc;
+ unsigned int __pyx_v_i;
+ PyObject *__pyx_v_label = NULL;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ int __pyx_t_1;
+ Py_ssize_t __pyx_t_2;
+ int __pyx_t_3;
+ PyObject *__pyx_t_4 = NULL;
+ size_t __pyx_t_5;
+ unsigned int __pyx_t_6;
+ PyObject *__pyx_t_7 = NULL;
+ PyObject *__pyx_t_8 = NULL;
+ int __pyx_t_9;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__getitem__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":23
+ *
+ * def __getitem__(self, int index):
+ * if not 0 <= index < len(self): # <<<<<<<<<<<<<<
+ * raise IndexError('lattice index out of range')
+ * arcs = []
+ */
+ __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_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
+ * 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_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;}
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":25
+ * if not 0 <= index < len(self):
+ * raise IndexError('lattice index out of range')
+ * arcs = [] # <<<<<<<<<<<<<<
+ * cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index]
+ * cdef lattice.LatticeArc* arc
+ */
+ __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_v_arcs = __pyx_t_4;
+ __pyx_t_4 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":26
+ * raise IndexError('lattice index out of range')
+ * arcs = []
+ * cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index] # <<<<<<<<<<<<<<
+ * cdef lattice.LatticeArc* arc
+ * cdef unsigned i
+ */
+ __pyx_v_arc_vector = ((__pyx_v_self->lattice[0])[__pyx_v_index]);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":29
+ * cdef lattice.LatticeArc* arc
+ * cdef unsigned i
+ * for i in range(arc_vector.size()): # <<<<<<<<<<<<<<
+ * arc = &arc_vector[i]
+ * label = unicode(TDConvert(arc.label), '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
+ * cdef unsigned i
+ * for i in range(arc_vector.size()):
+ * arc = &arc_vector[i] # <<<<<<<<<<<<<<
+ * label = unicode(TDConvert(arc.label), '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
+ * for i in range(arc_vector.size()):
+ * arc = &arc_vector[i]
+ * label = unicode(TDConvert(arc.label), 'utf8') # <<<<<<<<<<<<<<
+ * arcs.append((label, arc.cost, arc.dist2next))
+ * return tuple(arcs)
+ */
+ __pyx_t_4 = PyBytes_FromString(TD::Convert(__pyx_v_arc->label)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+ __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_7);
+ PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_4));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
+ 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_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
+ * arc = &arc_vector[i]
+ * label = unicode(TDConvert(arc.label), 'utf8')
+ * arcs.append((label, arc.cost, arc.dist2next)) # <<<<<<<<<<<<<<
+ * return tuple(arcs)
+ *
+ */
+ __pyx_t_4 = PyFloat_FromDouble(__pyx_v_arc->cost); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_t_7 = PyInt_FromLong(__pyx_v_arc->dist2next); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_7);
+ __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_8);
+ __Pyx_INCREF(((PyObject *)__pyx_v_label));
+ PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_label));
+ __Pyx_GIVEREF(((PyObject *)__pyx_v_label));
+ PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_4);
+ __Pyx_GIVEREF(__pyx_t_4);
+ PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
+ __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_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
+ }
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":33
+ * label = unicode(TDConvert(arc.label), 'utf8')
+ * arcs.append((label, arc.cost, arc.dist2next))
+ * return tuple(arcs) # <<<<<<<<<<<<<<
+ *
+ * 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_GOTREF(((PyObject *)__pyx_t_8));
+ __pyx_r = ((PyObject *)__pyx_t_8);
+ __pyx_t_8 = 0;
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_XDECREF(__pyx_t_7);
+ __Pyx_XDECREF(__pyx_t_8);
+ __Pyx_AddTraceback("_cdec.Lattice.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_arcs);
+ __Pyx_XDECREF(__pyx_v_label);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* 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) {
+ 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;}
+ }
+ goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
- __Pyx_AddTraceback("_cdec.Lattice.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_AddTraceback("_cdec.Lattice.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return -1;
__pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_plf_tuple), (&PyTuple_Type), 1, "plf_tuple", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_7Lattice___init__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), __pyx_v_plf_tuple);
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arcs), (&PyTuple_Type), 1, "arcs", 1))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_7Lattice_6__setitem__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), ((int)__pyx_v_index), ((PyObject*)__pyx_v_arcs));
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = -1;
@@ -2995,97 +12745,297 @@ static int __pyx_pw_5_cdec_7Lattice_1__init__(PyObject *__pyx_v_self, PyObject *
return __pyx_r;
}
-/* "_cdec.pyx":142
- * cdef lattice.Lattice* lattice
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":35
+ * return tuple(arcs)
*
- * def __init__(self, tuple plf_tuple): # <<<<<<<<<<<<<<
- * self.lattice = new lattice.Lattice()
- * cdef bytes plf = str(plf_tuple)
+ * def __setitem__(self, int index, tuple arcs): # <<<<<<<<<<<<<<
+ * if not 0 <= index < len(self):
+ * raise IndexError('lattice index out of range')
*/
-static int __pyx_pf_5_cdec_7Lattice___init__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, PyObject *__pyx_v_plf_tuple) {
- PyObject *__pyx_v_plf = 0;
+static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index, PyObject *__pyx_v_arcs) {
+ LatticeArc *__pyx_v_arc;
+ PyObject *__pyx_v_label = NULL;
+ PyObject *__pyx_v_cost = NULL;
+ PyObject *__pyx_v_dist2next = NULL;
int __pyx_r;
__Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- char *__pyx_t_3;
+ int __pyx_t_1;
+ Py_ssize_t __pyx_t_2;
+ int __pyx_t_3;
+ PyObject *__pyx_t_4 = NULL;
+ PyObject *__pyx_t_5 = NULL;
+ PyObject *__pyx_t_6 = NULL;
+ PyObject *__pyx_t_7 = NULL;
+ PyObject *__pyx_t_8 = NULL;
+ PyObject *__pyx_t_9 = NULL;
+ PyObject *(*__pyx_t_10)(PyObject *);
+ char *__pyx_t_11;
+ double __pyx_t_12;
+ int __pyx_t_13;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__init__", 0);
+ __Pyx_RefNannySetupContext("__setitem__", 0);
- /* "_cdec.pyx":143
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":36
*
- * def __init__(self, tuple plf_tuple):
- * self.lattice = new lattice.Lattice() # <<<<<<<<<<<<<<
- * cdef bytes plf = str(plf_tuple)
- * hypergraph.PLFtoLattice(string(<char *>plf), self.lattice)
+ * def __setitem__(self, int index, tuple arcs):
+ * if not 0 <= index < len(self): # <<<<<<<<<<<<<<
+ * raise IndexError('lattice index out of range')
+ * cdef lattice.LatticeArc* arc
*/
- __pyx_v_self->lattice = new 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_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
+ * 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_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;}
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
- /* "_cdec.pyx":144
- * def __init__(self, tuple plf_tuple):
- * self.lattice = new lattice.Lattice()
- * cdef bytes plf = str(plf_tuple) # <<<<<<<<<<<<<<
- * hypergraph.PLFtoLattice(string(<char *>plf), self.lattice)
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":39
+ * raise IndexError('lattice index out of range')
+ * cdef lattice.LatticeArc* arc
+ * for (label, cost, dist2next) in arcs: # <<<<<<<<<<<<<<
+ * if isinstance(label, unicode):
+ * label = label.encode('utf8')
+ */
+ if (unlikely(((PyObject *)__pyx_v_arcs) == Py_None)) {
+ PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+ {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ __pyx_t_4 = ((PyObject *)__pyx_v_arcs); __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = 0;
+ for (;;) {
+ if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++;
+ #else
+ __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
+ PyObject* sequence = __pyx_t_5;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 3)) {
+ if (size > 3) __Pyx_RaiseTooManyValuesError(3);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
+ if (likely(PyTuple_CheckExact(sequence))) {
+ __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
+ __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1);
+ __pyx_t_8 = PyTuple_GET_ITEM(sequence, 2);
+ } else {
+ __pyx_t_6 = PyList_GET_ITEM(sequence, 0);
+ __pyx_t_7 = PyList_GET_ITEM(sequence, 1);
+ __pyx_t_8 = PyList_GET_ITEM(sequence, 2);
+ }
+ __Pyx_INCREF(__pyx_t_6);
+ __Pyx_INCREF(__pyx_t_7);
+ __Pyx_INCREF(__pyx_t_8);
+ #else
+ __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ } else
+ {
+ 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_GOTREF(__pyx_t_9);
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
+ index = 0; __pyx_t_6 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
+ __Pyx_GOTREF(__pyx_t_6);
+ index = 1; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
+ __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;}
+ __pyx_t_10 = NULL;
+ __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+ goto __pyx_L7_unpacking_done;
+ __pyx_L6_unpacking_failed:;
+ __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+ __pyx_t_10 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_L7_unpacking_done:;
+ }
+ __Pyx_XDECREF(__pyx_v_label);
+ __pyx_v_label = __pyx_t_6;
+ __pyx_t_6 = 0;
+ __Pyx_XDECREF(__pyx_v_cost);
+ __pyx_v_cost = __pyx_t_7;
+ __pyx_t_7 = 0;
+ __Pyx_XDECREF(__pyx_v_dist2next);
+ __pyx_v_dist2next = __pyx_t_8;
+ __pyx_t_8 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":40
+ * 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)
+ * 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:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":42
+ * if isinstance(label, unicode):
+ * label = label.encode('utf8')
+ * arc = new lattice.LatticeArc(TDConvert(<char *>label), cost, dist2next) # <<<<<<<<<<<<<<
+ * self.lattice[0][index].push_back(arc[0])
+ * del arc
+ */
+ __pyx_t_11 = PyBytes_AsString(__pyx_v_label); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_cost); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_v_dist2next); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_arc = new LatticeArc(TD::Convert(((char *)__pyx_t_11)), __pyx_t_12, __pyx_t_13);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":43
+ * label = label.encode('utf8')
+ * arc = new lattice.LatticeArc(TDConvert(<char *>label), cost, dist2next)
+ * self.lattice[0][index].push_back(arc[0]) # <<<<<<<<<<<<<<
+ * del arc
*
*/
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(((PyObject *)__pyx_v_plf_tuple));
- PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_plf_tuple));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_plf_tuple));
- __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __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[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_v_plf = ((PyObject*)__pyx_t_2);
- __pyx_t_2 = 0;
+ ((__pyx_v_self->lattice[0])[__pyx_v_index]).push_back((__pyx_v_arc[0]));
- /* "_cdec.pyx":145
- * self.lattice = new lattice.Lattice()
- * cdef bytes plf = str(plf_tuple)
- * hypergraph.PLFtoLattice(string(<char *>plf), self.lattice) # <<<<<<<<<<<<<<
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":44
+ * arc = new lattice.LatticeArc(TDConvert(<char *>label), cost, dist2next)
+ * self.lattice[0][index].push_back(arc[0])
+ * del arc # <<<<<<<<<<<<<<
*
- * def __str__(self):
+ * def __len__(self):
*/
- __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_plf)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- HypergraphIO::PLFtoLattice(std::string(((char *)__pyx_t_3)), __pyx_v_self->lattice);
+ delete __pyx_v_arc;
+ }
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("_cdec.Lattice.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_XDECREF(__pyx_t_5);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_XDECREF(__pyx_t_7);
+ __Pyx_XDECREF(__pyx_t_8);
+ __Pyx_XDECREF(__pyx_t_9);
+ __Pyx_AddTraceback("_cdec.Lattice.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
- __Pyx_XDECREF(__pyx_v_plf);
+ __Pyx_XDECREF(__pyx_v_label);
+ __Pyx_XDECREF(__pyx_v_cost);
+ __Pyx_XDECREF(__pyx_v_dist2next);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_7Lattice_3__str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_7Lattice_3__str__(PyObject *__pyx_v_self) {
+static Py_ssize_t __pyx_pw_5_cdec_7Lattice_9__len__(PyObject *__pyx_v_self); /*proto*/
+static Py_ssize_t __pyx_pw_5_cdec_7Lattice_9__len__(PyObject *__pyx_v_self) {
+ Py_ssize_t __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_7Lattice_8__len__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":46
+ * del arc
+ *
+ * def __len__(self): # <<<<<<<<<<<<<<
+ * return self.lattice.size()
+ *
+ */
+
+static Py_ssize_t __pyx_pf_5_cdec_7Lattice_8__len__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
+ Py_ssize_t __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__len__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":47
+ *
+ * def __len__(self):
+ * return self.lattice.size() # <<<<<<<<<<<<<<
+ *
+ * def __str__(self):
+ */
+ __pyx_r = __pyx_v_self->lattice->size();
+ goto __pyx_L0;
+
+ __pyx_r = 0;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* 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) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_7Lattice_2__str__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_7Lattice_10__str__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "_cdec.pyx":147
- * hypergraph.PLFtoLattice(string(<char *>plf), self.lattice)
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":49
+ * return self.lattice.size()
*
* def __str__(self): # <<<<<<<<<<<<<<
- * return hypergraph.AsPLF(self.lattice[0]).c_str()
+ * return hypergraph.AsPLF(self.lattice[0], True).c_str()
*
*/
-static PyObject *__pyx_pf_5_cdec_7Lattice_2__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
+static PyObject *__pyx_pf_5_cdec_7Lattice_10__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
@@ -3094,15 +13044,15 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_2__str__(struct __pyx_obj_5_cdec_Latti
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__str__", 0);
- /* "_cdec.pyx":148
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":50
*
* def __str__(self):
- * return hypergraph.AsPLF(self.lattice[0]).c_str() # <<<<<<<<<<<<<<
+ * return hypergraph.AsPLF(self.lattice[0], True).c_str() # <<<<<<<<<<<<<<
*
* def __iter__(self):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->lattice[0]), NULL).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->lattice[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
__pyx_r = ((PyObject *)__pyx_t_1);
__pyx_t_1 = 0;
@@ -3119,143 +13069,5626 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_2__str__(struct __pyx_obj_5_cdec_Latti
__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_5__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_5_cdec_7Lattice_5__iter__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pw_5_cdec_7Lattice_13__iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_7Lattice_13__iter__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_7Lattice_4__iter__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5_cdec_7Lattice_12__iter__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "_cdec.pyx":150
- * return hypergraph.AsPLF(self.lattice[0]).c_str()
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":52
+ * return hypergraph.AsPLF(self.lattice[0], True).c_str()
*
* def __iter__(self): # <<<<<<<<<<<<<<
- * return iter(eval(str(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;
+ 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);
+ 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_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Lattice_14generator13, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_cur_scope);
+ __Pyx_RefNannyFinishContext();
+ return (PyObject *) gen;
+ }
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.Lattice.__iter__", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_7Lattice_14generator13(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+ struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *)__pyx_generator->closure);
+ PyObject *__pyx_r = NULL;
+ Py_ssize_t __pyx_t_1;
+ unsigned int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("None", 0);
+ switch (__pyx_generator->resume_label) {
+ case 0: goto __pyx_L3_first_run;
+ case 1: goto __pyx_L6_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[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":54
+ * def __iter__(self):
+ * cdef unsigned i
+ * for i in range(len(self)): # <<<<<<<<<<<<<<
+ * yield self[i]
+ *
+ */
+ __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
+ __pyx_cur_scope->__pyx_v_i = __pyx_t_2;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":55
+ * 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_GOTREF(__pyx_t_3);
+ __pyx_r = __pyx_t_3;
+ __pyx_t_3 = 0;
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 1;
+ return __pyx_r;
+ __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;}
+ }
+ PyErr_SetNone(PyExc_StopIteration);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("__iter__", __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_7Lattice_16todot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5_cdec_7Lattice_16todot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+ PyObject *__pyx_r = 0;
+ __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_RefNannyFinishContext();
+ return __pyx_r;
+}
+static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__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*/
+static PyMethodDef __pyx_mdef_5_cdec_7Lattice_5todot_1lines = {__Pyx_NAMESTR("lines"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_5todot_1lines, METH_NOARGS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pw_5_cdec_7Lattice_5todot_1lines(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("lines (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_7Lattice_5todot_lines(__pyx_self);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":58
+ *
+ * def todot(self):
+ * 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;
+ 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);
+ 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_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_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.Lattice.todot.lines", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator19(__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);
+ PyObject *__pyx_r = NULL;
+ PyObject *__pyx_t_1 = NULL;
+ Py_ssize_t __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ PyObject *(*__pyx_t_4)(PyObject *);
+ PyObject *__pyx_t_5 = NULL;
+ Py_ssize_t __pyx_t_6;
+ PyObject *(*__pyx_t_7)(PyObject *);
+ PyObject *__pyx_t_8 = NULL;
+ PyObject *__pyx_t_9 = NULL;
+ PyObject *__pyx_t_10 = NULL;
+ PyObject *__pyx_t_11 = NULL;
+ PyObject *(*__pyx_t_12)(PyObject *);
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("None", 0);
+ switch (__pyx_generator->resume_label) {
+ case 0: goto __pyx_L3_first_run;
+ case 1: goto __pyx_L4_resume_from_yield;
+ case 2: goto __pyx_L5_resume_from_yield;
+ case 3: goto __pyx_L6_resume_from_yield;
+ case 4: goto __pyx_L13_resume_from_yield;
+ case 5: goto __pyx_L14_resume_from_yield;
+ case 6: goto __pyx_L15_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[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":59
+ * def todot(self):
+ * 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_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;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":60
+ * 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_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;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":61
+ * 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_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;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":62
+ * 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;} }
+ __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_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_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_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_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_GOTREF(__pyx_t_3);
+ __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
+ }
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ for (;;) {
+ if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_3)) {
+ if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
+ #else
+ __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) {
+ if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
+ #else
+ __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_1 = __pyx_t_4(__pyx_t_3);
+ if (unlikely(!__pyx_t_1)) {
+ 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;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_1);
+ }
+ __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_i);
+ __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_i);
+ __Pyx_GIVEREF(__pyx_t_1);
+ __pyx_cur_scope->__pyx_v_i = __pyx_t_1;
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":63
+ * 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_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_GOTREF(__pyx_t_5);
+ __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext;
+ }
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ for (;;) {
+ if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_5)) {
+ if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++;
+ #else
+ __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_5)) {
+ if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++;
+ #else
+ __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_1 = __pyx_t_7(__pyx_t_5);
+ if (unlikely(!__pyx_t_1)) {
+ 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;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_1);
+ }
+ if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
+ PyObject* sequence = __pyx_t_1;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 3)) {
+ if (size > 3) __Pyx_RaiseTooManyValuesError(3);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
+ if (likely(PyTuple_CheckExact(sequence))) {
+ __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0);
+ __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1);
+ __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2);
+ } else {
+ __pyx_t_8 = PyList_GET_ITEM(sequence, 0);
+ __pyx_t_9 = PyList_GET_ITEM(sequence, 1);
+ __pyx_t_10 = PyList_GET_ITEM(sequence, 2);
+ }
+ __Pyx_INCREF(__pyx_t_8);
+ __Pyx_INCREF(__pyx_t_9);
+ __Pyx_INCREF(__pyx_t_10);
+ #else
+ __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ } else
+ {
+ Py_ssize_t index = -1;
+ __pyx_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_11);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
+ index = 0; __pyx_t_8 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_8)) goto __pyx_L11_unpacking_failed;
+ __Pyx_GOTREF(__pyx_t_8);
+ index = 1; __pyx_t_9 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_9)) goto __pyx_L11_unpacking_failed;
+ __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;}
+ __pyx_t_12 = NULL;
+ __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+ goto __pyx_L12_unpacking_done;
+ __pyx_L11_unpacking_failed:;
+ __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+ __pyx_t_12 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_L12_unpacking_done:;
+ }
+ __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_label);
+ __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_label);
+ __Pyx_GIVEREF(__pyx_t_8);
+ __pyx_cur_scope->__pyx_v_label = __pyx_t_8;
+ __pyx_t_8 = 0;
+ __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_weight);
+ __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_weight);
+ __Pyx_GIVEREF(__pyx_t_9);
+ __pyx_cur_scope->__pyx_v_weight = __pyx_t_9;
+ __pyx_t_9 = 0;
+ __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_delta);
+ __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_delta);
+ __Pyx_GIVEREF(__pyx_t_10);
+ __pyx_cur_scope->__pyx_v_delta = __pyx_t_10;
+ __pyx_t_10 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":64
+ * 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_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_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_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_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);
+ __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_i);
+ PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_1);
+ __Pyx_GIVEREF(__pyx_t_1);
+ PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_9);
+ __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_GOTREF(((PyObject *)__pyx_t_9));
+ __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
+ __pyx_r = ((PyObject *)__pyx_t_9);
+ __pyx_t_9 = 0;
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
+ __Pyx_XGIVEREF(__pyx_t_3);
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
+ __pyx_cur_scope->__pyx_t_2 = __pyx_t_4;
+ __Pyx_XGIVEREF(__pyx_t_5);
+ __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
+ __pyx_cur_scope->__pyx_t_4 = __pyx_t_6;
+ __pyx_cur_scope->__pyx_t_5 = __pyx_t_7;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 4;
+ return __pyx_r;
+ __pyx_L13_resume_from_yield:;
+ __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
+ __pyx_t_3 = __pyx_cur_scope->__pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = 0;
+ __Pyx_XGOTREF(__pyx_t_3);
+ __pyx_t_4 = __pyx_cur_scope->__pyx_t_2;
+ __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
+ __pyx_cur_scope->__pyx_t_3 = 0;
+ __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;}
+ }
+ __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
+ * for label, weight, delta in self[i]:
+ * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"'))
+ * yield '%d [shape=doublecircle]' % len(self) # <<<<<<<<<<<<<<
+ * yield '}'
+ * return '\n'.join(lines()).encode('utf8')
+ */
+ __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_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_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_GOTREF(((PyObject *)__pyx_t_5));
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_r = ((PyObject *)__pyx_t_5);
+ __pyx_t_5 = 0;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __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;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":66
+ * 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_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;}
+ PyErr_SetNone(PyExc_StopIteration);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_5);
+ __Pyx_XDECREF(__pyx_t_8);
+ __Pyx_XDECREF(__pyx_t_9);
+ __Pyx_XDECREF(__pyx_t_10);
+ __Pyx_XDECREF(__pyx_t_11);
+ __Pyx_AddTraceback("lines", __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;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":57
+ * yield self[i]
*
+ * def todot(self): # <<<<<<<<<<<<<<
+ * def lines():
+ * yield 'digraph lattice {'
*/
-static PyObject *__pyx_pf_5_cdec_7Lattice_4__iter__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
+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;
+ PyObject *__pyx_v_lines = 0;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ int __pyx_lineno = 0;
+ 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);
+ 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);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":58
+ *
+ * def todot(self):
+ * 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_GOTREF(__pyx_t_1);
+ __pyx_v_lines = __pyx_t_1;
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":67
+ * yield '%d [shape=doublecircle]' % len(self)
+ * yield '}'
+ * return '\n'.join(lines()).encode('utf8') # <<<<<<<<<<<<<<
+ */
+ __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_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_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_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_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_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_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("_cdec.Lattice.todot", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_lines);
+ __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":3
+ * cimport mteval
+ *
+ * cdef SufficientStats as_stats(x, y): # <<<<<<<<<<<<<<
+ * if isinstance(x, SufficientStats):
+ * return x
+ */
+
+static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+ struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_stats = NULL;
+ struct __pyx_obj_5_cdec_SufficientStats *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_t_2;
+ int __pyx_t_3;
+ int __pyx_t_4;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("as_stats", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":4
+ *
+ * cdef SufficientStats as_stats(x, y):
+ * if isinstance(x, SufficientStats): # <<<<<<<<<<<<<<
+ * return x
+ * elif x == 0 and isinstance(y, SufficientStats):
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SufficientStats));
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_x, __pyx_t_1);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ if (__pyx_t_2) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":5
+ * cdef SufficientStats as_stats(x, y):
+ * if isinstance(x, SufficientStats):
+ * return x # <<<<<<<<<<<<<<
+ * elif x == 0 and isinstance(y, SufficientStats):
+ * stats = SufficientStats()
+ */
+ __Pyx_XDECREF(((PyObject *)__pyx_r));
+ if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SufficientStats))))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_INCREF(__pyx_v_x);
+ __pyx_r = ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_v_x);
+ goto __pyx_L0;
+ goto __pyx_L3;
+ }
+
+ /* "/Users/vchahun/Sandbox/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_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) {
+ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SufficientStats));
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_y, __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) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":7
+ * return x
+ * elif x == 0 and isinstance(y, SufficientStats):
+ * stats = SufficientStats() # <<<<<<<<<<<<<<
+ * stats.stats = new mteval.SufficientStats()
+ * stats.metric = (<SufficientStats> y).metric
+ */
+ __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 = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __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
+ * elif x == 0 and isinstance(y, SufficientStats):
+ * stats = SufficientStats()
+ * stats.stats = new mteval.SufficientStats() # <<<<<<<<<<<<<<
+ * stats.metric = (<SufficientStats> y).metric
+ * return stats
+ */
+ __pyx_v_stats->stats = new SufficientStats();
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":9
+ * stats = SufficientStats()
+ * stats.stats = new mteval.SufficientStats()
+ * stats.metric = (<SufficientStats> y).metric # <<<<<<<<<<<<<<
+ * return stats
+ *
+ */
+ __pyx_v_stats->metric = ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_v_y)->metric;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":10
+ * stats.stats = new mteval.SufficientStats()
+ * stats.metric = (<SufficientStats> y).metric
+ * return stats # <<<<<<<<<<<<<<
+ *
+ * cdef class Candidate:
+ */
+ __Pyx_XDECREF(((PyObject *)__pyx_r));
+ __Pyx_INCREF(((PyObject *)__pyx_v_stats));
+ __pyx_r = __pyx_v_stats;
+ goto __pyx_L0;
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ __pyx_r = ((struct __pyx_obj_5_cdec_SufficientStats *)Py_None); __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.as_stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = 0;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_stats);
+ __Pyx_XGIVEREF((PyObject *)__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_9Candidate_5words_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_9Candidate_5words_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_9Candidate_5words___get__(((struct __pyx_obj_5_cdec_Candidate *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":17
+ *
+ * property words:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * return unicode(GetString(self.candidate.ewords).c_str(), encoding='utf8')
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_9Candidate_5words___get__(struct __pyx_obj_5_cdec_Candidate *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = 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":18
+ * property words:
+ * def __get__(self):
+ * return unicode(GetString(self.candidate.ewords).c_str(), encoding='utf8') # <<<<<<<<<<<<<<
+ *
+ * property fmap:
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __pyx_t_1 = PyBytes_FromString(TD::GetString(__pyx_v_self->candidate->ewords).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; __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[5]; __pyx_lineno = 18; __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 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+ if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+ __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_2);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("_cdec.Candidate.words.__get__", __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_9Candidate_4fmap_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_9Candidate_4fmap_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_9Candidate_4fmap___get__(((struct __pyx_obj_5_cdec_Candidate *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":21
+ *
+ * property fmap:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef SparseVector fmap = SparseVector.__new__(SparseVector)
+ * fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap)
+ */
+
+static PyObject *__pyx_pf_5_cdec_9Candidate_4fmap___get__(struct __pyx_obj_5_cdec_Candidate *__pyx_v_self) {
+ struct __pyx_obj_5_cdec_SparseVector *__pyx_v_fmap = 0;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__get__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":22
+ * property fmap:
+ * def __get__(self):
+ * cdef SparseVector fmap = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<<
+ * fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap)
+ * return fmap
+ */
+ __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_fmap = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":23
+ * def __get__(self):
+ * cdef SparseVector fmap = SparseVector.__new__(SparseVector)
+ * fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap) # <<<<<<<<<<<<<<
+ * return fmap
+ *
+ */
+ __pyx_v_fmap->vector = new FastSparseVector<weight_t>(__pyx_v_self->candidate->fmap);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":24
+ * cdef SparseVector fmap = SparseVector.__new__(SparseVector)
+ * fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap)
+ * return fmap # <<<<<<<<<<<<<<
+ *
+ * cdef class SufficientStats:
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_fmap));
+ __pyx_r = ((PyObject *)__pyx_v_fmap);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.Candidate.fmap.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_fmap);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_9Candidate_5score_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_9Candidate_5score_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_9Candidate_5score___get__(((struct __pyx_obj_5_cdec_Candidate *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":14
+ * cdef class Candidate:
+ * cdef mteval.const_Candidate* candidate
+ * cdef public float score # <<<<<<<<<<<<<<
+ *
+ * property words:
+ */
+
+static PyObject *__pyx_pf_5_cdec_9Candidate_5score___get__(struct __pyx_obj_5_cdec_Candidate *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__get__", 0);
+ __Pyx_XDECREF(__pyx_r);
+ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->score); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __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_AddTraceback("_cdec.Candidate.score.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_9Candidate_5score_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pw_5_cdec_9Candidate_5score_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_9Candidate_5score_2__set__(((struct __pyx_obj_5_cdec_Candidate *)__pyx_v_self), ((PyObject *)__pyx_v_value));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static int __pyx_pf_5_cdec_9Candidate_5score_2__set__(struct __pyx_obj_5_cdec_Candidate *__pyx_v_self, PyObject *__pyx_v_value) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ float __pyx_t_1;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__set__", 0);
+ __pyx_t_1 = __pyx_PyFloat_AsFloat(__pyx_v_value); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_self->score = __pyx_t_1;
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.Candidate.score.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static void __pyx_pw_5_cdec_15SufficientStats_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_5_cdec_15SufficientStats_1__dealloc__(PyObject *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+ __pyx_pf_5_cdec_15SufficientStats___dealloc__(((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":30
+ * cdef mteval.EvaluationMetric* metric
+ *
+ * def __dealloc__(self): # <<<<<<<<<<<<<<
+ * del self.stats
+ *
+ */
+
+static void __pyx_pf_5_cdec_15SufficientStats___dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":31
+ *
+ * def __dealloc__(self):
+ * del self.stats # <<<<<<<<<<<<<<
+ *
+ * property score:
+ */
+ delete __pyx_v_self->stats;
+
+ __Pyx_RefNannyFinishContext();
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_15SufficientStats_5score_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_15SufficientStats_5score_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_15SufficientStats_5score___get__(((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":34
+ *
+ * property score:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * return self.metric.ComputeScore(self.stats[0])
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_15SufficientStats_5score___get__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__get__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":35
+ * property score:
+ * def __get__(self):
+ * return self.metric.ComputeScore(self.stats[0]) # <<<<<<<<<<<<<<
+ *
+ * property detail:
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->metric->ComputeScore((__pyx_v_self->stats[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __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_AddTraceback("_cdec.SufficientStats.score.__get__", __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_15SufficientStats_6detail_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_15SufficientStats_6detail_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_15SufficientStats_6detail___get__(((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":38
+ *
+ * property detail:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * return self.metric.DetailedScore(self.stats[0]).c_str()
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_15SufficientStats_6detail___get__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__get__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":39
+ * property detail:
+ * def __get__(self):
+ * return 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_1 = 0;
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.SufficientStats.detail.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static Py_ssize_t __pyx_pw_5_cdec_15SufficientStats_3__len__(PyObject *__pyx_v_self); /*proto*/
+static Py_ssize_t __pyx_pw_5_cdec_15SufficientStats_3__len__(PyObject *__pyx_v_self) {
+ Py_ssize_t __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_15SufficientStats_2__len__(((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":41
+ * return self.metric.DetailedScore(self.stats[0]).c_str()
+ *
+ * def __len__(self): # <<<<<<<<<<<<<<
+ * return self.stats.size()
+ *
+ */
+
+static Py_ssize_t __pyx_pf_5_cdec_15SufficientStats_2__len__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self) {
+ Py_ssize_t __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__len__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":42
+ *
+ * def __len__(self):
+ * return self.stats.size() # <<<<<<<<<<<<<<
+ *
+ * def __iter__(self):
+ */
+ __pyx_r = __pyx_v_self->stats->size();
+ goto __pyx_L0;
+
+ __pyx_r = 0;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator14(__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*/
+static PyObject *__pyx_pw_5_cdec_15SufficientStats_5__iter__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_15SufficientStats_4__iter__(((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/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]
+ */
+
+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;
+ 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);
+ 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_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_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.SufficientStats.__iter__", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator14(__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);
+ PyObject *__pyx_r = NULL;
+ Py_ssize_t __pyx_t_1;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ PyObject *(*__pyx_t_4)(PyObject *);
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("None", 0);
+ switch (__pyx_generator->resume_label) {
+ case 0: goto __pyx_L3_first_run;
+ case 1: goto __pyx_L6_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[5]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- /* "_cdec.pyx":151
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":45
+ *
+ * def __iter__(self):
+ * 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[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __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[5]; __pyx_lineno = 45; __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_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
+ __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
+ __pyx_t_4 = NULL;
+ } else {
+ __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
+ }
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ for (;;) {
+ if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_3)) {
+ if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) {
+ if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_2 = __pyx_t_4(__pyx_t_3);
+ if (unlikely(!__pyx_t_2)) {
+ if (PyErr_Occurred()) {
+ if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
+ else {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_2);
+ }
+ __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_i);
+ __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_i);
+ __Pyx_GIVEREF(__pyx_t_2);
+ __pyx_cur_scope->__pyx_v_i = __pyx_t_2;
+ __pyx_t_2 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":46
* def __iter__(self):
- * return iter(eval(str(self))) # <<<<<<<<<<<<<<
+ * for i in range(len(self)):
+ * yield self[i] # <<<<<<<<<<<<<<
+ *
+ * def __getitem__(self, int index):
+ */
+ __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_i); if (!__pyx_t_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __pyx_r = __pyx_t_2;
+ __pyx_t_2 = 0;
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __Pyx_XGIVEREF(__pyx_t_3);
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
+ __pyx_cur_scope->__pyx_t_2 = __pyx_t_4;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 1;
+ return __pyx_r;
+ __pyx_L6_resume_from_yield:;
+ __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
+ __pyx_t_3 = __pyx_cur_scope->__pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = 0;
+ __Pyx_XGOTREF(__pyx_t_3);
+ __pyx_t_4 = __pyx_cur_scope->__pyx_t_2;
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ PyErr_SetNone(PyExc_StopIteration);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_2);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("__iter__", __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_15SufficientStats_8__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index); /*proto*/
+static PyObject *__pyx_pw_5_cdec_15SufficientStats_8__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[5]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("_cdec.SufficientStats.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_15SufficientStats_7__getitem__(((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_v_self), ((int)__pyx_v_index));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":48
+ * yield self[i]
+ *
+ * def __getitem__(self, int index): # <<<<<<<<<<<<<<
+ * if not 0 <= index < len(self):
+ * raise IndexError('sufficient stats vector index out of range')
+ */
+
+static PyObject *__pyx_pf_5_cdec_15SufficientStats_7__getitem__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self, int __pyx_v_index) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ int __pyx_t_1;
+ Py_ssize_t __pyx_t_2;
+ int __pyx_t_3;
+ PyObject *__pyx_t_4 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__getitem__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":49
+ *
+ * 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_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[5]; __pyx_lineno = 49; __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/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_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[5]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "/Users/vchahun/Sandbox/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] # <<<<<<<<<<<<<<
+ *
+ * def __iadd__(SufficientStats self, SufficientStats other):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __pyx_t_4 = PyFloat_FromDouble(((__pyx_v_self->stats[0])[__pyx_v_index])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_r = __pyx_t_4;
+ __pyx_t_4 = 0;
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_4);
+ __Pyx_AddTraceback("_cdec.SufficientStats.__getitem__", __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_15SufficientStats_10__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
+static PyObject *__pyx_pw_5_cdec_15SufficientStats_10__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__iadd__ (wrapper)", 0);
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SufficientStats, 1, "other", 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_15SufficientStats_9__iadd__(((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_v_other));
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":53
+ * return self.stats[0][index]
+ *
+ * def __iadd__(SufficientStats self, SufficientStats other): # <<<<<<<<<<<<<<
+ * self.stats[0] += other.stats[0]
+ * return self
+ */
+
+static PyObject *__pyx_pf_5_cdec_15SufficientStats_9__iadd__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self, struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_other) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__iadd__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":54
+ *
+ * def __iadd__(SufficientStats self, SufficientStats other):
+ * self.stats[0] += other.stats[0] # <<<<<<<<<<<<<<
+ * return self
+ *
+ */
+ (__pyx_v_self->stats[0]) += (__pyx_v_other->stats[0]);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":55
+ * def __iadd__(SufficientStats self, SufficientStats other):
+ * self.stats[0] += other.stats[0]
+ * return self # <<<<<<<<<<<<<<
+ *
+ * def __add__(x, y):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_self));
+ __pyx_r = ((PyObject *)__pyx_v_self);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_15SufficientStats_12__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
+static PyObject *__pyx_pw_5_cdec_15SufficientStats_12__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_15SufficientStats_11__add__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":57
+ * return self
+ *
+ * def __add__(x, y): # <<<<<<<<<<<<<<
+ * cdef SufficientStats sx = as_stats(x, y)
+ * cdef SufficientStats sy = as_stats(y, x)
+ */
+
+static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+ struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_sx = 0;
+ struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_sy = 0;
+ struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_result = 0;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__add__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":58
+ *
+ * def __add__(x, y):
+ * cdef SufficientStats sx = as_stats(x, y) # <<<<<<<<<<<<<<
+ * cdef SufficientStats sy = as_stats(y, x)
+ * cdef SufficientStats result = SufficientStats()
+ */
+ __pyx_t_1 = ((PyObject *)__pyx_f_5_cdec_as_stats(__pyx_v_x, __pyx_v_y)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __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
+ * def __add__(x, y):
+ * cdef SufficientStats sx = as_stats(x, y)
+ * cdef SufficientStats sy = as_stats(y, x) # <<<<<<<<<<<<<<
+ * cdef SufficientStats result = SufficientStats()
+ * result.stats = new mteval.SufficientStats(mteval.add(sx.stats[0], sy.stats[0]))
+ */
+ __pyx_t_1 = ((PyObject *)__pyx_f_5_cdec_as_stats(__pyx_v_y, __pyx_v_x)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __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
+ * cdef SufficientStats sx = as_stats(x, y)
+ * cdef SufficientStats sy = as_stats(y, x)
+ * cdef SufficientStats result = SufficientStats() # <<<<<<<<<<<<<<
+ * result.stats = new mteval.SufficientStats(mteval.add(sx.stats[0], sy.stats[0]))
+ * result.metric = sx.metric
+ */
+ __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 = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __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
+ * cdef SufficientStats sy = as_stats(y, x)
+ * cdef SufficientStats result = SufficientStats()
+ * result.stats = new mteval.SufficientStats(mteval.add(sx.stats[0], sy.stats[0])) # <<<<<<<<<<<<<<
+ * result.metric = sx.metric
+ * return result
+ */
+ __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
+ * cdef SufficientStats result = SufficientStats()
+ * result.stats = new mteval.SufficientStats(mteval.add(sx.stats[0], sy.stats[0]))
+ * result.metric = sx.metric # <<<<<<<<<<<<<<
+ * return result
+ *
+ */
+ __pyx_v_result->metric = __pyx_v_sx->metric;
+
+ /* "/Users/vchahun/Sandbox/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 # <<<<<<<<<<<<<<
+ *
+ * cdef class CandidateSet:
+ */
+ __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_AddTraceback("_cdec.SufficientStats.__add__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_sx);
+ __Pyx_XDECREF((PyObject *)__pyx_v_sy);
+ __Pyx_XDECREF((PyObject *)__pyx_v_result);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_12CandidateSet_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5_cdec_12CandidateSet_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ struct __pyx_obj_5_cdec_SegmentEvaluator *__pyx_v_evaluator = 0;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
+ {
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__evaluator,0};
+ PyObject* values[1] = {0};
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args;
+ const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+ switch (pos_args) {
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ kw_args = PyDict_Size(__pyx_kwds);
+ switch (pos_args) {
+ case 0:
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__evaluator)) != 0)) kw_args--;
+ else goto __pyx_L5_argtuple_error;
+ }
+ if (unlikely(kw_args > 0)) {
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 70; __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_evaluator = ((struct __pyx_obj_5_cdec_SegmentEvaluator *)values[0]);
+ }
+ 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[5]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("_cdec.CandidateSet.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return -1;
+ __pyx_L4_argument_unpacking_done:;
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_evaluator), __pyx_ptype_5_cdec_SegmentEvaluator, 1, "evaluator", 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12CandidateSet___cinit__(((struct __pyx_obj_5_cdec_CandidateSet *)__pyx_v_self), __pyx_v_evaluator);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":70
+ * cdef mteval.CandidateSet* cs
+ *
+ * def __cinit__(self, SegmentEvaluator evaluator): # <<<<<<<<<<<<<<
+ * self.scorer = new shared_ptr[mteval.SegmentEvaluator](evaluator.scorer[0])
+ * self.metric = evaluator.metric
+ */
+
+static int __pyx_pf_5_cdec_12CandidateSet___cinit__(struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self, struct __pyx_obj_5_cdec_SegmentEvaluator *__pyx_v_evaluator) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__cinit__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":71
+ *
+ * def __cinit__(self, SegmentEvaluator evaluator):
+ * self.scorer = new shared_ptr[mteval.SegmentEvaluator](evaluator.scorer[0]) # <<<<<<<<<<<<<<
+ * self.metric = evaluator.metric
+ * self.cs = new mteval.CandidateSet()
+ */
+ __pyx_v_self->scorer = new boost::shared_ptr<SegmentEvaluator>((__pyx_v_evaluator->scorer[0]));
+
+ /* "/Users/vchahun/Sandbox/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 # <<<<<<<<<<<<<<
+ * self.cs = new mteval.CandidateSet()
+ *
+ */
+ __pyx_v_self->metric = __pyx_v_evaluator->metric;
+
+ /* "/Users/vchahun/Sandbox/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() # <<<<<<<<<<<<<<
*
* def __dealloc__(self):
*/
+ __pyx_v_self->cs = new training::CandidateSet();
+
+ __pyx_r = 0;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static void __pyx_pw_5_cdec_12CandidateSet_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_5_cdec_12CandidateSet_3__dealloc__(PyObject *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+ __pyx_pf_5_cdec_12CandidateSet_2__dealloc__(((struct __pyx_obj_5_cdec_CandidateSet *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":75
+ * self.cs = new mteval.CandidateSet()
+ *
+ * def __dealloc__(self): # <<<<<<<<<<<<<<
+ * del self.scorer
+ * del self.cs
+ */
+
+static void __pyx_pf_5_cdec_12CandidateSet_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":76
+ *
+ * def __dealloc__(self):
+ * del self.scorer # <<<<<<<<<<<<<<
+ * del self.cs
+ *
+ */
+ delete __pyx_v_self->scorer;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":77
+ * def __dealloc__(self):
+ * del self.scorer
+ * del self.cs # <<<<<<<<<<<<<<
+ *
+ * def __len__(self):
+ */
+ delete __pyx_v_self->cs;
+
+ __Pyx_RefNannyFinishContext();
+}
+
+/* Python wrapper */
+static Py_ssize_t __pyx_pw_5_cdec_12CandidateSet_5__len__(PyObject *__pyx_v_self); /*proto*/
+static Py_ssize_t __pyx_pw_5_cdec_12CandidateSet_5__len__(PyObject *__pyx_v_self) {
+ Py_ssize_t __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_12CandidateSet_4__len__(((struct __pyx_obj_5_cdec_CandidateSet *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":79
+ * del self.cs
+ *
+ * def __len__(self): # <<<<<<<<<<<<<<
+ * return self.cs.size()
+ *
+ */
+
+static Py_ssize_t __pyx_pf_5_cdec_12CandidateSet_4__len__(struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self) {
+ Py_ssize_t __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__len__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":80
+ *
+ * def __len__(self):
+ * return self.cs.size() # <<<<<<<<<<<<<<
+ *
+ * def __getitem__(self,int k):
+ */
+ __pyx_r = __pyx_v_self->cs->size();
+ goto __pyx_L0;
+
+ __pyx_r = 0;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_12CandidateSet_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12CandidateSet_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) {
+ int __pyx_v_k;
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
+ assert(__pyx_arg_k); {
+ __pyx_v_k = __Pyx_PyInt_AsInt(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("_cdec.CandidateSet.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_12CandidateSet_6__getitem__(((struct __pyx_obj_5_cdec_CandidateSet *)__pyx_v_self), ((int)__pyx_v_k));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":82
+ * return self.cs.size()
+ *
+ * def __getitem__(self,int k): # <<<<<<<<<<<<<<
+ * if not 0 <= k < self.cs.size():
+ * raise IndexError('candidate set index out of range')
+ */
+
+static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self, int __pyx_v_k) {
+ struct __pyx_obj_5_cdec_Candidate *__pyx_v_candidate = 0;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ int __pyx_t_1;
+ int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__getitem__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":83
+ *
+ * def __getitem__(self,int k):
+ * if not 0 <= k < self.cs.size(): # <<<<<<<<<<<<<<
+ * raise IndexError('candidate set index out of range')
+ * cdef Candidate candidate = Candidate()
+ */
+ __pyx_t_1 = (0 <= __pyx_v_k);
+ if (__pyx_t_1) {
+ __pyx_t_1 = (__pyx_v_k < __pyx_v_self->cs->size());
+ }
+ __pyx_t_2 = (!__pyx_t_1);
+ if (__pyx_t_2) {
+
+ /* "/Users/vchahun/Sandbox/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_GOTREF(__pyx_t_3);
+ __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ {__pyx_filename = __pyx_f[5]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "/Users/vchahun/Sandbox/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() # <<<<<<<<<<<<<<
+ * candidate.candidate = &self.cs[0][k]
+ * candidate.score = self.metric.ComputeScore(self.cs[0][k].eval_feats)
+ */
+ __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Candidate)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __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
+ * raise IndexError('candidate set index out of range')
+ * cdef Candidate candidate = Candidate()
+ * candidate.candidate = &self.cs[0][k] # <<<<<<<<<<<<<<
+ * candidate.score = self.metric.ComputeScore(self.cs[0][k].eval_feats)
+ * return candidate
+ */
+ __pyx_v_candidate->candidate = (&((__pyx_v_self->cs[0])[__pyx_v_k]));
+
+ /* "/Users/vchahun/Sandbox/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) # <<<<<<<<<<<<<<
+ * return candidate
+ *
+ */
+ __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
+ * candidate.candidate = &self.cs[0][k]
+ * candidate.score = self.metric.ComputeScore(self.cs[0][k].eval_feats)
+ * return candidate # <<<<<<<<<<<<<<
+ *
+ * def __iter__(self):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_candidate));
+ __pyx_r = ((PyObject *)__pyx_v_candidate);
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("_cdec.CandidateSet.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_candidate);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator15(__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*/
+static PyObject *__pyx_pw_5_cdec_12CandidateSet_9__iter__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_12CandidateSet_8__iter__(((struct __pyx_obj_5_cdec_CandidateSet *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":90
+ * return candidate
+ *
+ * def __iter__(self): # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * for i in range(len(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;
+ 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);
+ 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_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_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.CandidateSet.__iter__", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator15(__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);
+ PyObject *__pyx_r = NULL;
+ Py_ssize_t __pyx_t_1;
+ unsigned int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("None", 0);
+ switch (__pyx_generator->resume_label) {
+ case 0: goto __pyx_L3_first_run;
+ case 1: goto __pyx_L6_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[5]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":92
+ * 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[5]; __pyx_lineno = 92; __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/mteval.pxi":93
+ * cdef unsigned i
+ * for i in range(len(self)):
+ * yield self[i] # <<<<<<<<<<<<<<
+ *
+ * def add_kbest(self, Hypergraph hypergraph, unsigned k):
+ */
+ __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[5]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_r = __pyx_t_3;
+ __pyx_t_3 = 0;
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 1;
+ return __pyx_r;
+ __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[5]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ PyErr_SetNone(PyExc_StopIteration);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_L0:;
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_generator->resume_label = -1;
+ __Pyx_Generator_clear((PyObject*)__pyx_generator);
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_12CandidateSet_12add_kbest(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+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;
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("add_kbest (wrapper)", 0);
+ {
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__hypergraph,&__pyx_n_s__k,0};
+ PyObject* values[2] = {0,0};
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args;
+ const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+ switch (pos_args) {
+ case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ kw_args = PyDict_Size(__pyx_kwds);
+ switch (pos_args) {
+ case 0:
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__hypergraph)) != 0)) kw_args--;
+ else goto __pyx_L5_argtuple_error;
+ case 1:
+ if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__k)) != 0)) kw_args--;
+ else {
+ __Pyx_RaiseArgtupleInvalid("add_kbest", 1, 2, 2, 1); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ }
+ if (unlikely(kw_args > 0)) {
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_kbest") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+ goto __pyx_L5_argtuple_error;
+ } else {
+ values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ }
+ __pyx_v_hypergraph = ((struct __pyx_obj_5_cdec_Hypergraph *)values[0]);
+ __pyx_v_k = __Pyx_PyInt_AsUnsignedInt(values[1]); if (unlikely((__pyx_v_k == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L5_argtuple_error:;
+ __Pyx_RaiseArgtupleInvalid("add_kbest", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("_cdec.CandidateSet.add_kbest", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ __pyx_L4_argument_unpacking_done:;
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hypergraph), __pyx_ptype_5_cdec_Hypergraph, 1, "hypergraph", 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12CandidateSet_11add_kbest(((struct __pyx_obj_5_cdec_CandidateSet *)__pyx_v_self), __pyx_v_hypergraph, __pyx_v_k);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/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())
+ *
+ */
+
+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) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("add_kbest", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":96
+ *
+ * def add_kbest(self, Hypergraph hypergraph, unsigned k):
+ * self.cs.AddKBestCandidates(hypergraph.hg[0], k, self.scorer.get()) # <<<<<<<<<<<<<<
+ *
+ * cdef class SegmentEvaluator:
+ */
+ __pyx_v_self->cs->AddKBestCandidates((__pyx_v_hypergraph->hg[0]), __pyx_v_k, __pyx_v_self->scorer->get());
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static void __pyx_pw_5_cdec_16SegmentEvaluator_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_5_cdec_16SegmentEvaluator_1__dealloc__(PyObject *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+ __pyx_pf_5_cdec_16SegmentEvaluator___dealloc__(((struct __pyx_obj_5_cdec_SegmentEvaluator *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":102
+ * cdef mteval.EvaluationMetric* metric
+ *
+ * def __dealloc__(self): # <<<<<<<<<<<<<<
+ * del self.scorer
+ *
+ */
+
+static void __pyx_pf_5_cdec_16SegmentEvaluator___dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_SegmentEvaluator *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":103
+ *
+ * def __dealloc__(self):
+ * del self.scorer # <<<<<<<<<<<<<<
+ *
+ * def evaluate(self, sentence):
+ */
+ delete __pyx_v_self->scorer;
+
+ __Pyx_RefNannyFinishContext();
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_3evaluate(PyObject *__pyx_v_self, PyObject *__pyx_v_sentence); /*proto*/
+static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_3evaluate(PyObject *__pyx_v_self, PyObject *__pyx_v_sentence) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("evaluate (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_16SegmentEvaluator_2evaluate(((struct __pyx_obj_5_cdec_SegmentEvaluator *)__pyx_v_self), ((PyObject *)__pyx_v_sentence));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":105
+ * del self.scorer
+ *
+ * def evaluate(self, sentence): # <<<<<<<<<<<<<<
+ * 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) {
+ std::vector<WordID> __pyx_v_hyp;
+ struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_sf = 0;
+ 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("evaluate", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":107
+ * def evaluate(self, sentence):
+ * 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_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
+ * cdef vector[WordID] hyp
+ * cdef SufficientStats sf = SufficientStats()
+ * sf.metric = self.metric # <<<<<<<<<<<<<<
+ * sf.stats = new mteval.SufficientStats()
+ * ConvertSentence(string(as_str(sentence.strip())), &hyp)
+ */
+ __pyx_v_sf->metric = __pyx_v_self->metric;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":109
+ * cdef SufficientStats sf = SufficientStats()
+ * sf.metric = self.metric
+ * sf.stats = new mteval.SufficientStats() # <<<<<<<<<<<<<<
+ * ConvertSentence(string(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
+ * sf.metric = self.metric
+ * sf.stats = new mteval.SufficientStats()
+ * ConvertSentence(string(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_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_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_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":111
+ * sf.stats = new mteval.SufficientStats()
+ * ConvertSentence(string(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)
+ * self.scorer.get().Evaluate(hyp, sf.stats)
+ * return sf # <<<<<<<<<<<<<<
+ *
+ * def candidate_set(self):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_sf));
+ __pyx_r = ((PyObject *)__pyx_v_sf);
+ 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.SegmentEvaluator.evaluate", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_sf);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_5candidate_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_5candidate_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("candidate_set (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_16SegmentEvaluator_4candidate_set(((struct __pyx_obj_5_cdec_SegmentEvaluator *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":114
+ * return sf
+ *
+ * def candidate_set(self): # <<<<<<<<<<<<<<
+ * return CandidateSet(self)
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_4candidate_set(struct __pyx_obj_5_cdec_SegmentEvaluator *__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("candidate_set", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":115
+ *
+ * def candidate_set(self):
+ * 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_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[0]; __pyx_lineno = 151; __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 = 115; __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 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __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.SegmentEvaluator.candidate_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_6Scorer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5_cdec_6Scorer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ PyObject *__pyx_v_name = 0;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
+ {
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__name,0};
+ PyObject* values[1] = {0};
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":121
+ * cdef mteval.EvaluationMetric* metric
+ *
+ * def __cinit__(self, bytes name=None): # <<<<<<<<<<<<<<
+ * if name:
+ * self.name = new string(name)
+ */
+ values[0] = ((PyObject*)Py_None);
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args;
+ const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+ switch (pos_args) {
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ kw_args = PyDict_Size(__pyx_kwds);
+ switch (pos_args) {
+ case 0:
+ if (kw_args > 0) {
+ PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
+ if (value) { values[0] = value; kw_args--; }
+ }
+ }
+ if (unlikely(kw_args > 0)) {
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ } else {
+ switch (PyTuple_GET_SIZE(__pyx_args)) {
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ }
+ __pyx_v_name = ((PyObject*)values[0]);
+ }
+ 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_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;}
+ __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:;
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static int __pyx_pf_5_cdec_6Scorer___cinit__(struct __pyx_obj_5_cdec_Scorer *__pyx_v_self, PyObject *__pyx_v_name) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ int __pyx_t_1;
+ char *__pyx_t_2;
+ 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
+ *
+ * def __cinit__(self, bytes name=None):
+ * if name: # <<<<<<<<<<<<<<
+ * self.name = new string(name)
+ * self.metric = mteval.MetricInstance(self.name[0])
+ */
+ __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
+ * 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);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":124
+ * if name:
+ * self.name = new string(name)
+ * self.metric = mteval.MetricInstance(self.name[0]) # <<<<<<<<<<<<<<
+ *
+ * def __dealloc__(self):
+ */
+ __pyx_v_self->metric = EvaluationMetric::Instance((__pyx_v_self->name[0]));
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("_cdec.Scorer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static void __pyx_pw_5_cdec_6Scorer_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_5_cdec_6Scorer_3__dealloc__(PyObject *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+ __pyx_pf_5_cdec_6Scorer_2__dealloc__(((struct __pyx_obj_5_cdec_Scorer *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":126
+ * self.metric = mteval.MetricInstance(self.name[0])
+ *
+ * def __dealloc__(self): # <<<<<<<<<<<<<<
+ * del self.name
+ *
+ */
+
+static void __pyx_pf_5_cdec_6Scorer_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Scorer *__pyx_v_self) {
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__dealloc__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":127
+ *
+ * def __dealloc__(self):
+ * del self.name # <<<<<<<<<<<<<<
+ *
+ * def __call__(self, refs):
+ */
+ delete __pyx_v_self->name;
+
+ __Pyx_RefNannyFinishContext();
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_6Scorer_5__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_5_cdec_6Scorer_5__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ PyObject *__pyx_v_refs = 0;
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
+ {
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__refs,0};
+ PyObject* values[1] = {0};
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args;
+ const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+ switch (pos_args) {
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ kw_args = PyDict_Size(__pyx_kwds);
+ switch (pos_args) {
+ case 0:
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__refs)) != 0)) kw_args--;
+ else goto __pyx_L5_argtuple_error;
+ }
+ if (unlikely(kw_args > 0)) {
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 129; __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_refs = values[0];
+ }
+ 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_L3_error:;
+ __Pyx_AddTraceback("_cdec.Scorer.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_6Scorer_4__call__(((struct __pyx_obj_5_cdec_Scorer *)__pyx_v_self), __pyx_v_refs);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":129
+ * del self.name
+ *
+ * def __call__(self, refs): # <<<<<<<<<<<<<<
+ * if isinstance(refs, unicode) or isinstance(refs, str):
+ * refs = [refs]
+ */
+
+static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Scorer *__pyx_v_self, PyObject *__pyx_v_refs) {
+ std::vector<std::vector<WordID> > *__pyx_v_refsv;
+ std::vector<WordID> *__pyx_v_refv;
+ PyObject *__pyx_v_ref = NULL;
+ struct __pyx_obj_5_cdec_SegmentEvaluator *__pyx_v_evaluator = 0;
+ PyObject *__pyx_r = NULL;
+ __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;
+ PyObject *__pyx_t_8 = NULL;
+ 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
+ *
+ * def __call__(self, refs):
+ * if isinstance(refs, unicode) or isinstance(refs, str): # <<<<<<<<<<<<<<
+ * refs = [refs]
+ * cdef vector[vector[WordID]]* refsv = new vector[vector[WordID]]()
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)(&PyUnicode_Type)));
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_refs, __pyx_t_1);
+ __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) {
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":131
+ * def __call__(self, refs):
+ * if isinstance(refs, unicode) or isinstance(refs, str):
+ * 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_GOTREF(__pyx_t_1);
+ __Pyx_INCREF(__pyx_v_refs);
+ PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_refs);
+ __Pyx_GIVEREF(__pyx_v_refs);
+ __Pyx_DECREF(__pyx_v_refs);
+ __pyx_v_refs = ((PyObject *)__pyx_t_1);
+ __pyx_t_1 = 0;
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":132
+ * if isinstance(refs, unicode) or isinstance(refs, str):
+ * refs = [refs]
+ * cdef vector[vector[WordID]]* refsv = new vector[vector[WordID]]() # <<<<<<<<<<<<<<
+ * cdef vector[WordID]* refv
+ * cdef bytes ref_str
+ */
+ __pyx_v_refsv = new std::vector<std::vector<WordID> >();
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":135
+ * cdef vector[WordID]* refv
+ * cdef bytes ref_str
+ * for ref in refs: # <<<<<<<<<<<<<<
+ * refv = new vector[WordID]()
+ * ConvertSentence(string(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;
+ } 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_GOTREF(__pyx_t_1);
+ __pyx_t_6 = 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 CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_7 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++;
+ #else
+ __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++;
+ #else
+ __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_7 = __pyx_t_6(__pyx_t_1);
+ if (unlikely(!__pyx_t_7)) {
+ 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;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_7);
+ }
+ __Pyx_XDECREF(__pyx_v_ref);
+ __pyx_v_ref = __pyx_t_7;
+ __pyx_t_7 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":136
+ * cdef bytes ref_str
+ * for ref in refs:
+ * refv = new vector[WordID]() # <<<<<<<<<<<<<<
+ * ConvertSentence(string(as_str(ref.strip())), refv)
+ * refsv.push_back(refv[0])
+ */
+ __pyx_v_refv = new std::vector<WordID>();
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":137
+ * for ref in refs:
+ * refv = new vector[WordID]()
+ * ConvertSentence(string(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_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_8); __pyx_t_8 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":138
+ * refv = new vector[WordID]()
+ * ConvertSentence(string(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)
+ * refsv.push_back(refv[0])
+ * del refv # <<<<<<<<<<<<<<
+ * cdef unsigned i
+ * cdef SegmentEvaluator evaluator = SegmentEvaluator()
+ */
+ delete __pyx_v_refv;
+ }
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":141
+ * 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_GOTREF(__pyx_t_1);
- __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(((PyObject *)__pyx_t_3));
- if (((PyObject *)__pyx_v_self)) {
- if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __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
+ * cdef unsigned i
+ * cdef SegmentEvaluator evaluator = SegmentEvaluator()
+ * evaluator.metric = self.metric # <<<<<<<<<<<<<<
+ * evaluator.scorer = new shared_ptr[mteval.SegmentEvaluator](
+ * self.metric.CreateSegmentEvaluator(refsv[0]))
+ */
+ __pyx_v_evaluator->metric = __pyx_v_self->metric;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":143
+ * cdef SegmentEvaluator evaluator = SegmentEvaluator()
+ * evaluator.metric = self.metric
+ * evaluator.scorer = new shared_ptr[mteval.SegmentEvaluator]( # <<<<<<<<<<<<<<
+ * self.metric.CreateSegmentEvaluator(refsv[0]))
+ * del refsv # in theory should not delete but store in SegmentEvaluator
+ */
+ __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
+ * evaluator.scorer = new shared_ptr[mteval.SegmentEvaluator](
+ * self.metric.CreateSegmentEvaluator(refsv[0]))
+ * del refsv # in theory should not delete but store in SegmentEvaluator # <<<<<<<<<<<<<<
+ * return evaluator
+ *
+ */
+ delete __pyx_v_refsv;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":146
+ * self.metric.CreateSegmentEvaluator(refsv[0]))
+ * del refsv # in theory should not delete but store in SegmentEvaluator
+ * return evaluator # <<<<<<<<<<<<<<
+ *
+ * def __str__(self):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_evaluator));
+ __pyx_r = ((PyObject *)__pyx_v_evaluator);
+ 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_7);
+ __Pyx_XDECREF(__pyx_t_8);
+ __Pyx_AddTraceback("_cdec.Scorer.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_ref);
+ __Pyx_XDECREF((PyObject *)__pyx_v_evaluator);
+ __Pyx_XDECREF(__pyx_v_refs);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_6Scorer_7__str__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_6Scorer_7__str__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_6Scorer_6__str__(((struct __pyx_obj_5_cdec_Scorer *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":148
+ * return evaluator
+ *
+ * def __str__(self): # <<<<<<<<<<<<<<
+ * return self.name.c_str()
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_6Scorer_6__str__(struct __pyx_obj_5_cdec_Scorer *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__str__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":149
+ *
+ * def __str__(self):
+ * return 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_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_r = ((PyObject *)__pyx_t_1);
+ __pyx_t_1 = 0;
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.Scorer.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":151
+ * return self.name.c_str()
+ *
+ * cdef float _compute_score(void* metric_, mteval.SufficientStats* stats): # <<<<<<<<<<<<<<
+ * cdef Metric metric = <Metric> metric_
+ * cdef list ss = []
+ */
+
+static float __pyx_f_5_cdec__compute_score(void *__pyx_v_metric_, SufficientStats *__pyx_v_stats) {
+ struct __pyx_obj_5_cdec_Metric *__pyx_v_metric = 0;
+ PyObject *__pyx_v_ss = 0;
+ unsigned int __pyx_v_i;
+ float __pyx_r;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ unsigned int __pyx_t_2;
+ unsigned int __pyx_t_3;
+ int __pyx_t_4;
+ PyObject *__pyx_t_5 = NULL;
+ PyObject *__pyx_t_6 = NULL;
+ float __pyx_t_7;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("_compute_score", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":152
+ *
+ * cdef float _compute_score(void* metric_, mteval.SufficientStats* stats):
+ * cdef Metric metric = <Metric> metric_ # <<<<<<<<<<<<<<
+ * cdef list ss = []
+ * cdef unsigned i
+ */
+ __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
+ * 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_GOTREF(__pyx_t_1);
+ __pyx_v_ss = __pyx_t_1;
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":155
+ * cdef list ss = []
+ * cdef unsigned i
+ * for i in range(stats.size()): # <<<<<<<<<<<<<<
+ * ss.append(stats[0][i])
+ * return metric.score(ss)
+ */
+ __pyx_t_2 = __pyx_v_stats->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":156
+ * 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_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_DECREF(__pyx_t_1); __pyx_t_1 = 0;
}
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_1));
- __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
- PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_t_3));
- __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":157
+ * 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_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_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_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_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __pyx_r = __pyx_t_7;
+ goto __pyx_L0;
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_5);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_WriteUnraisable("_cdec._compute_score", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = 0;
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_metric);
+ __Pyx_XDECREF(__pyx_v_ss);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":159
+ * return metric.score(ss)
+ *
+ * cdef void _compute_sufficient_stats(void* metric_, # <<<<<<<<<<<<<<
+ * string* hyp,
+ * vector[string]* refs,
+ */
+
+static void __pyx_f_5_cdec__compute_sufficient_stats(void *__pyx_v_metric_, std::string *__pyx_v_hyp, std::vector<std::string> *__pyx_v_refs, SufficientStats *__pyx_v_out) {
+ struct __pyx_obj_5_cdec_Metric *__pyx_v_metric = 0;
+ PyObject *__pyx_v_refs_ = 0;
+ unsigned int __pyx_v_i;
+ PyObject *__pyx_v_ss = 0;
+ __Pyx_RefNannyDeclarations
+ 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_6 = NULL;
+ Py_ssize_t __pyx_t_7;
+ float __pyx_t_8;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("_compute_sufficient_stats", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":163
+ * vector[string]* refs,
+ * mteval.SufficientStats* out):
+ * cdef Metric metric = <Metric> metric_ # <<<<<<<<<<<<<<
+ * cdef list refs_ = []
+ * cdef unsigned i
+ */
+ __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
+ * 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_GOTREF(__pyx_t_1);
+ __pyx_v_refs_ = __pyx_t_1;
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":166
+ * 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_)
+ */
+ __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
+ * 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_)
+ * 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_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;
+ }
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":168
+ * for i in range(refs.size()):
+ * refs_.append(refs[0][i].c_str())
+ * cdef list ss = metric.evaluate(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_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_GOTREF(__pyx_t_6);
+ PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
+ __Pyx_INCREF(((PyObject *)__pyx_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_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;
+
+ /* "/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_)
+ * 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_t_7 = PyList_GET_SIZE(((PyObject *)__pyx_v_ss)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_out->fields.resize(__pyx_t_7);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":170
+ * cdef list ss = metric.evaluate(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 = 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 = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_7; __pyx_t_3+=1) {
+ __pyx_v_i = __pyx_t_3;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":171
+ * out.fields.resize(len(ss))
+ * for i in range(len(ss)):
+ * out.fields[i] = ss[i] # <<<<<<<<<<<<<<
+ *
+ * cdef class Metric:
+ */
+ if (unlikely(((PyObject *)__pyx_v_ss) == Py_None)) {
+ PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+ {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ __pyx_t_5 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_ss), __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_5); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_6);
+ __Pyx_WriteUnraisable("_cdec._compute_sufficient_stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_L0:;
+ __Pyx_XDECREF((PyObject *)__pyx_v_metric);
+ __Pyx_XDECREF(__pyx_v_refs_);
+ __Pyx_XDECREF(__pyx_v_ss);
+ __Pyx_RefNannyFinishContext();
+}
+
+/* Python wrapper */
+static int __pyx_pw_5_cdec_6Metric_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5_cdec_6Metric_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ 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_6Metric___cinit__(((struct __pyx_obj_5_cdec_Metric *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":175
+ * cdef class Metric:
+ * cdef Scorer scorer
+ * def __cinit__(self): # <<<<<<<<<<<<<<
+ * self.scorer = Scorer()
+ * self.scorer.name = new string(as_str(self.__class__.__name__))
+ */
+
+static int __pyx_pf_5_cdec_6Metric___cinit__(struct __pyx_obj_5_cdec_Metric *__pyx_v_self) {
+ int __pyx_r;
+ __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("__cinit__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":176
+ * 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],
+ */
+ __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_GOTREF(__pyx_t_1);
+ __Pyx_GIVEREF(__pyx_t_1);
+ __Pyx_GOTREF(__pyx_v_self->scorer);
+ __Pyx_DECREF(((PyObject *)__pyx_v_self->scorer));
+ __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
+ * 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],
+ * <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_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_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;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":178
+ * self.scorer = Scorer()
+ * self.scorer.name = new string(as_str(self.__class__.__name__))
+ * self.scorer.metric = mteval.PyMetricInstance(self.scorer.name[0], # <<<<<<<<<<<<<<
+ * <void*> self, _compute_sufficient_stats, _compute_score)
+ *
+ */
+ __pyx_v_self->scorer->metric = PythonEvaluationMetric::Instance((__pyx_v_self->scorer->name[0]), ((void *)__pyx_v_self), __pyx_f_5_cdec__compute_sufficient_stats, __pyx_f_5_cdec__compute_score);
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_2);
+ __Pyx_AddTraceback("_cdec.Metric.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_6Metric_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_5_cdec_6Metric_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ PyObject *__pyx_v_refs = 0;
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
+ {
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__refs,0};
+ PyObject* values[1] = {0};
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args;
+ const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+ switch (pos_args) {
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ kw_args = PyDict_Size(__pyx_kwds);
+ switch (pos_args) {
+ case 0:
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__refs)) != 0)) kw_args--;
+ else goto __pyx_L5_argtuple_error;
+ }
+ if (unlikely(kw_args > 0)) {
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 181; __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_refs = values[0];
+ }
+ 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_L3_error:;
+ __Pyx_AddTraceback("_cdec.Metric.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_6Metric_2__call__(((struct __pyx_obj_5_cdec_Metric *)__pyx_v_self), __pyx_v_refs);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":181
+ * <void*> self, _compute_sufficient_stats, _compute_score)
+ *
+ * def __call__(self, refs): # <<<<<<<<<<<<<<
+ * return self.scorer(refs)
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_6Metric_2__call__(struct __pyx_obj_5_cdec_Metric *__pyx_v_self, PyObject *__pyx_v_refs) {
+ 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("__call__", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":182
+ *
+ * def __call__(self, refs):
+ * return self.scorer(refs) # <<<<<<<<<<<<<<
+ *
+ * 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_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_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.Metric.__call__", __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_6Metric_5score(PyObject *__pyx_v_stats, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5_cdec_6Metric_5score(PyObject *__pyx_v_stats, CYTHON_UNUSED PyObject *unused) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("score (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_6Metric_4score(((struct __pyx_obj_5_cdec_Metric *)__pyx_v_stats));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":184
+ * return self.scorer(refs)
+ *
+ * def score(SufficientStats stats): # <<<<<<<<<<<<<<
+ * return 0
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_6Metric_4score(CYTHON_UNUSED struct __pyx_obj_5_cdec_Metric *__pyx_v_stats) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("score", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":185
+ *
+ * def score(SufficientStats stats):
+ * return 0 # <<<<<<<<<<<<<<
+ *
+ * def evaluate(self, hyp, refs):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(__pyx_int_0);
+ __pyx_r = __pyx_int_0;
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_6Metric_7evaluate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pw_5_cdec_6Metric_7evaluate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ CYTHON_UNUSED PyObject *__pyx_v_hyp = 0;
+ CYTHON_UNUSED PyObject *__pyx_v_refs = 0;
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("evaluate (wrapper)", 0);
+ {
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__hyp,&__pyx_n_s__refs,0};
+ PyObject* values[2] = {0,0};
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args;
+ const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+ switch (pos_args) {
+ case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ kw_args = PyDict_Size(__pyx_kwds);
+ switch (pos_args) {
+ case 0:
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__hyp)) != 0)) kw_args--;
+ else goto __pyx_L5_argtuple_error;
+ 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;}
+ }
+ }
+ 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;}
+ }
+ } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+ goto __pyx_L5_argtuple_error;
+ } else {
+ values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ }
+ __pyx_v_hyp = values[0];
+ __pyx_v_refs = values[1];
+ }
+ 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_L3_error:;
+ __Pyx_AddTraceback("_cdec.Metric.evaluate", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_6Metric_6evaluate(((struct __pyx_obj_5_cdec_Metric *)__pyx_v_self), __pyx_v_hyp, __pyx_v_refs);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":187
+ * return 0
+ *
+ * def evaluate(self, hyp, refs): # <<<<<<<<<<<<<<
+ * return []
+ *
+ */
+
+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) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("evaluate", 0);
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":188
+ *
+ * def evaluate(self, hyp, refs):
+ * return [] # <<<<<<<<<<<<<<
+ *
+ * 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_GOTREF(__pyx_t_1);
+ __pyx_r = ((PyObject *)__pyx_t_1);
__pyx_t_1 = 0;
- __pyx_t_3 = 0;
- __pyx_t_3 = PyObject_Call(__pyx_builtin_eval, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __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 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __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;
- __pyx_t_4 = 0;
goto __pyx_L0;
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.Metric.evaluate", __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_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) {
+ 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_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "_cdec.pyx":28
+ * class ParseFailed(Exception): pass
+ *
+ * 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;
+ 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);
+ if (unlikely(!__pyx_cur_scope)) {
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ }
+ __Pyx_GOTREF(__pyx_cur_scope);
+ __pyx_cur_scope->__pyx_v_config = __pyx_v_config;
+ __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_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._make_config", __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;
+}
+
+static PyObject *__pyx_gb_5_cdec_4generator16(__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);
+ PyObject *__pyx_r = NULL;
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ Py_ssize_t __pyx_t_3;
+ PyObject *(*__pyx_t_4)(PyObject *);
+ PyObject *__pyx_t_5 = NULL;
+ PyObject *__pyx_t_6 = NULL;
+ PyObject *__pyx_t_7 = NULL;
+ PyObject *(*__pyx_t_8)(PyObject *);
+ int __pyx_t_9;
+ Py_ssize_t __pyx_t_10;
+ PyObject *(*__pyx_t_11)(PyObject *);
+ PyObject *__pyx_t_12 = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("None", 0);
+ switch (__pyx_generator->resume_label) {
+ case 0: goto __pyx_L3_first_run;
+ case 1: goto __pyx_L13_resume_from_yield;
+ case 2: goto __pyx_L16_resume_from_yield;
+ case 3: goto __pyx_L17_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[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "_cdec.pyx":29
+ *
+ * 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_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_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_GOTREF(__pyx_t_1);
+ __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
+ }
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ for (;;) {
+ if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_2 = __pyx_t_4(__pyx_t_1);
+ if (unlikely(!__pyx_t_2)) {
+ 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;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_2);
+ }
+ if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
+ PyObject* sequence = __pyx_t_2;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 2)) {
+ if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
+ if (likely(PyTuple_CheckExact(sequence))) {
+ __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
+ __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
+ } else {
+ __pyx_t_5 = PyList_GET_ITEM(sequence, 0);
+ __pyx_t_6 = PyList_GET_ITEM(sequence, 1);
+ }
+ __Pyx_INCREF(__pyx_t_5);
+ __Pyx_INCREF(__pyx_t_6);
+ #else
+ __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ } else
+ {
+ Py_ssize_t index = -1;
+ __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_7);
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
+ index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
+ __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;}
+ __pyx_t_8 = NULL;
+ __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+ goto __pyx_L7_unpacking_done;
+ __pyx_L6_unpacking_failed:;
+ __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+ __pyx_t_8 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_L7_unpacking_done:;
+ }
+ __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key);
+ __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_key);
+ __Pyx_GIVEREF(__pyx_t_5);
+ __pyx_cur_scope->__pyx_v_key = __pyx_t_5;
+ __pyx_t_5 = 0;
+ __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_value);
+ __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_value);
+ __Pyx_GIVEREF(__pyx_t_6);
+ __pyx_cur_scope->__pyx_v_value = __pyx_t_6;
+ __pyx_t_6 = 0;
+
+ /* "_cdec.pyx":30
+ * def _make_config(config):
+ * for key, value in config.items():
+ * if isinstance(value, dict): # <<<<<<<<<<<<<<
+ * for name, info in value.items():
+ * yield key, '%s %s' % (name, info)
+ */
+ __pyx_t_2 = ((PyObject *)((PyObject*)(&PyDict_Type)));
+ __Pyx_INCREF(__pyx_t_2);
+ __pyx_t_9 = __Pyx_TypeCheck(__pyx_cur_scope->__pyx_v_value, __pyx_t_2);
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ if (__pyx_t_9) {
+
+ /* "_cdec.pyx":31
+ * 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_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_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_GOTREF(__pyx_t_2);
+ __pyx_t_11 = Py_TYPE(__pyx_t_2)->tp_iternext;
+ }
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ for (;;) {
+ if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_2)) {
+ if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++;
+ #else
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_2)) {
+ if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++;
+ #else
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_6 = __pyx_t_11(__pyx_t_2);
+ if (unlikely(!__pyx_t_6)) {
+ 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;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_6);
+ }
+ if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
+ PyObject* sequence = __pyx_t_6;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 2)) {
+ if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
+ if (likely(PyTuple_CheckExact(sequence))) {
+ __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
+ __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1);
+ } else {
+ __pyx_t_5 = PyList_GET_ITEM(sequence, 0);
+ __pyx_t_7 = PyList_GET_ITEM(sequence, 1);
+ }
+ __Pyx_INCREF(__pyx_t_5);
+ __Pyx_INCREF(__pyx_t_7);
+ #else
+ __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ } else
+ {
+ Py_ssize_t index = -1;
+ __pyx_t_12 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_12);
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __pyx_t_8 = Py_TYPE(__pyx_t_12)->tp_iternext;
+ index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_12); if (unlikely(!__pyx_t_5)) goto __pyx_L11_unpacking_failed;
+ __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;}
+ __pyx_t_8 = NULL;
+ __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+ goto __pyx_L12_unpacking_done;
+ __pyx_L11_unpacking_failed:;
+ __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+ __pyx_t_8 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_L12_unpacking_done:;
+ }
+ __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_name);
+ __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_name);
+ __Pyx_GIVEREF(__pyx_t_5);
+ __pyx_cur_scope->__pyx_v_name = __pyx_t_5;
+ __pyx_t_5 = 0;
+ __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_info);
+ __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_info);
+ __Pyx_GIVEREF(__pyx_t_7);
+ __pyx_cur_scope->__pyx_v_info = __pyx_t_7;
+ __pyx_t_7 = 0;
+
+ /* "_cdec.pyx":32
+ * 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_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);
+ __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_name);
+ __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_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_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);
+ __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key);
+ PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_t_7));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
+ __pyx_t_7 = 0;
+ __pyx_r = ((PyObject *)__pyx_t_6);
+ __pyx_t_6 = 0;
+ __Pyx_XGIVEREF(__pyx_t_1);
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __Pyx_XGIVEREF(__pyx_t_2);
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
+ __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
+ __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
+ __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 1;
+ return __pyx_r;
+ __pyx_L13_resume_from_yield:;
+ __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
+ __pyx_cur_scope->__pyx_t_0 = 0;
+ __Pyx_XGOTREF(__pyx_t_1);
+ __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = 0;
+ __Pyx_XGOTREF(__pyx_t_2);
+ __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
+ __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;}
+ }
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ goto __pyx_L8;
+ }
+
+ /* "_cdec.pyx":33
+ * for name, info in value.items():
+ * yield key, '%s %s' % (name, info)
+ * elif isinstance(value, list): # <<<<<<<<<<<<<<
+ * for name in value:
+ * yield key, name
+ */
+ __pyx_t_2 = ((PyObject *)((PyObject*)(&PyList_Type)));
+ __Pyx_INCREF(__pyx_t_2);
+ __pyx_t_9 = __Pyx_TypeCheck(__pyx_cur_scope->__pyx_v_value, __pyx_t_2);
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ if (__pyx_t_9) {
+
+ /* "_cdec.pyx":34
+ * yield key, '%s %s' % (name, info)
+ * elif isinstance(value, list):
+ * for name in value: # <<<<<<<<<<<<<<
+ * yield key, name
+ * else:
+ */
+ if (PyList_CheckExact(__pyx_cur_scope->__pyx_v_value) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_value)) {
+ __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_GOTREF(__pyx_t_2);
+ __pyx_t_11 = Py_TYPE(__pyx_t_2)->tp_iternext;
+ }
+ for (;;) {
+ if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_2)) {
+ if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++;
+ #else
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_2)) {
+ if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++;
+ #else
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_6 = __pyx_t_11(__pyx_t_2);
+ if (unlikely(!__pyx_t_6)) {
+ 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;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_6);
+ }
+ __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_name);
+ __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_name);
+ __Pyx_GIVEREF(__pyx_t_6);
+ __pyx_cur_scope->__pyx_v_name = __pyx_t_6;
+ __pyx_t_6 = 0;
+
+ /* "_cdec.pyx":35
+ * elif isinstance(value, list):
+ * for name in value:
+ * yield key, name # <<<<<<<<<<<<<<
+ * else:
+ * yield key, bytes(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_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);
+ __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key);
+ __Pyx_INCREF(__pyx_cur_scope->__pyx_v_name);
+ PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_cur_scope->__pyx_v_name);
+ __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_name);
+ __pyx_r = ((PyObject *)__pyx_t_6);
+ __pyx_t_6 = 0;
+ __Pyx_XGIVEREF(__pyx_t_1);
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __Pyx_XGIVEREF(__pyx_t_2);
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
+ __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
+ __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
+ __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
+ __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 2;
+ return __pyx_r;
+ __pyx_L16_resume_from_yield:;
+ __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
+ __pyx_cur_scope->__pyx_t_0 = 0;
+ __Pyx_XGOTREF(__pyx_t_1);
+ __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
+ __pyx_cur_scope->__pyx_t_1 = 0;
+ __Pyx_XGOTREF(__pyx_t_2);
+ __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
+ __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;}
+ }
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ goto __pyx_L8;
+ }
+ /*else*/ {
+
+ /* "_cdec.pyx":37
+ * yield key, name
+ * else:
+ * yield key, bytes(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_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_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_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);
+ __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_key);
+ PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_6);
+ __Pyx_GIVEREF(__pyx_t_6);
+ __pyx_t_6 = 0;
+ __pyx_r = ((PyObject *)__pyx_t_2);
+ __pyx_t_2 = 0;
+ __Pyx_XGIVEREF(__pyx_t_1);
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
+ __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
+ __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 3;
+ return __pyx_r;
+ __pyx_L17_resume_from_yield:;
+ __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
+ __pyx_cur_scope->__pyx_t_0 = 0;
+ __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;}
+ }
+ __pyx_L8:;
+ }
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ PyErr_SetNone(PyExc_StopIteration);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("_cdec.Lattice.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_XDECREF(__pyx_t_5);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_XDECREF(__pyx_t_7);
+ __Pyx_XDECREF(__pyx_t_12);
+ __Pyx_AddTraceback("_make_config", __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 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) {
+ PyObject *__pyx_v_config_str = 0;
+ PyObject *__pyx_v_config = 0;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
+ __pyx_v_config = PyDict_New(); if (unlikely(!__pyx_v_config)) return -1;
+ __Pyx_GOTREF(__pyx_v_config);
+ {
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__config_str,0};
+ PyObject* values[1] = {0};
+
+ /* "_cdec.pyx":43
+ * cdef DenseVector weights
+ *
+ * def __cinit__(self, config_str=None, **config): # <<<<<<<<<<<<<<
+ * """ Configuration can be given as a string:
+ * Decoder('formalism = scfg')
+ */
+ values[0] = ((PyObject *)Py_None);
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args;
+ const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+ switch (pos_args) {
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ kw_args = PyDict_Size(__pyx_kwds);
+ switch (pos_args) {
+ case 0:
+ if (kw_args > 0) {
+ PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__config_str);
+ if (value) { values[0] = value; kw_args--; }
+ }
+ }
+ 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;}
+ }
+ } else {
+ switch (PyTuple_GET_SIZE(__pyx_args)) {
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ }
+ __pyx_v_config_str = values[0];
+ }
+ 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_L3_error:;
+ __Pyx_CLEAR(__pyx_v_config);
+ __Pyx_AddTraceback("_cdec.Decoder.__cinit__", __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_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 */
+
+/* "_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)
+ */
+
+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;
+ 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);
+ 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_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_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.Decoder.__cinit__.genexpr", __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;
}
+static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator20(__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);
+ PyObject *__pyx_r = NULL;
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ Py_ssize_t __pyx_t_4;
+ PyObject *(*__pyx_t_5)(PyObject *);
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("None", 0);
+ switch (__pyx_generator->resume_label) {
+ case 0: goto __pyx_L3_first_run;
+ case 1: goto __pyx_L6_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[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;}
+ __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;}
+ __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_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+ if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
+ __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_GOTREF(__pyx_t_2);
+ __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
+ }
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ for (;;) {
+ if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_2)) {
+ if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
+ #else
+ __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_2)) {
+ if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
+ #else
+ __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_3 = __pyx_t_5(__pyx_t_2);
+ if (unlikely(!__pyx_t_3)) {
+ 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;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_3);
+ }
+ __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_kv);
+ __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_kv);
+ __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_GOTREF(((PyObject *)__pyx_t_3));
+ __pyx_r = ((PyObject *)__pyx_t_3);
+ __pyx_t_3 = 0;
+ __Pyx_XGIVEREF(__pyx_t_2);
+ __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
+ __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
+ __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ /* return from generator, yielding value */
+ __pyx_generator->resume_label = 1;
+ return __pyx_r;
+ __pyx_L6_resume_from_yield:;
+ __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
+ __pyx_cur_scope->__pyx_t_0 = 0;
+ __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;}
+ }
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ PyErr_SetNone(PyExc_StopIteration);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_2);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("genexpr", __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;
+}
+
+/* "_cdec.pyx":43
+ * cdef DenseVector weights
+ *
+ * def __cinit__(self, config_str=None, **config): # <<<<<<<<<<<<<<
+ * """ Configuration can be given as a string:
+ * Decoder('formalism = scfg')
+ */
+
+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;
+ PyObject *__pyx_v_formalism = NULL;
+ std::istringstream *__pyx_v_config_stream;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ int __pyx_t_1;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ int __pyx_t_4;
+ int __pyx_t_5;
+ PyObject *__pyx_t_6 = NULL;
+ char *__pyx_t_7;
+ 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);
+ if (unlikely(!__pyx_cur_scope)) {
+ __Pyx_RefNannyFinishContext();
+ return -1;
+ }
+ __Pyx_GOTREF(__pyx_cur_scope);
+ __pyx_cur_scope->__pyx_v_config = __pyx_v_config;
+ __Pyx_INCREF(__pyx_cur_scope->__pyx_v_config);
+ __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_config);
+ __Pyx_INCREF(__pyx_v_config_str);
+
+ /* "_cdec.pyx":49
+ * Decoder(formalism='scfg')
+ * """
+ * if config_str is None: # <<<<<<<<<<<<<<
+ * formalism = config.get('formalism', None)
+ * if formalism not in ('scfg', 'fst', 'lextrans', 'pb',
+ */
+ __pyx_t_1 = (__pyx_v_config_str == Py_None);
+ if (__pyx_t_1) {
+
+ /* "_cdec.pyx":50
+ * """
+ * 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_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_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
+ * if config_str is None:
+ * formalism = config.get('formalism', None)
+ * if formalism not in ('scfg', 'fst', 'lextrans', 'pb', # <<<<<<<<<<<<<<
+ * 'csplit', 'tagger', 'lexalign'):
+ * raise InvalidConfig('formalism "%s" unknown' % formalism)
+ */
+ __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;}
+ 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_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_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_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_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_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_1 = ((int)__pyx_t_5);
+ } else {
+ __pyx_t_1 = __pyx_t_4;
+ }
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_t_4 = __pyx_t_1;
+ if (__pyx_t_4) {
+
+ /* "_cdec.pyx":53
+ * 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_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_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_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_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;}
+ goto __pyx_L4;
+ }
+ __pyx_L4:;
+
+ /* "_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)
+ */
+ __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_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_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_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_GOTREF(__pyx_t_6);
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __Pyx_DECREF(__pyx_v_config_str);
+ __pyx_v_config_str = __pyx_t_6;
+ __pyx_t_6 = 0;
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "_cdec.pyx":55
+ * 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_v_config_stream = new std::istringstream(__pyx_t_7);
+
+ /* "_cdec.pyx":56
+ * 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
+ * self.weights = DenseVector.__new__(DenseVector)
+ */
+ __pyx_v_self->dec = new Decoder(__pyx_v_config_stream);
+
+ /* "_cdec.pyx":57
+ * cdef istringstream* config_stream = new istringstream(config_str)
+ * self.dec = new decoder.Decoder(config_stream)
+ * del config_stream # <<<<<<<<<<<<<<
+ * self.weights = DenseVector.__new__(DenseVector)
+ * self.weights.vector = &self.dec.CurrentWeightVector()
+ */
+ delete __pyx_v_config_stream;
+
+ /* "_cdec.pyx":58
+ * 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_GOTREF(__pyx_t_6);
+ if (!(likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5_cdec_DenseVector)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GIVEREF(__pyx_t_6);
+ __Pyx_GOTREF(__pyx_v_self->weights);
+ __Pyx_DECREF(((PyObject *)__pyx_v_self->weights));
+ __pyx_v_self->weights = ((struct __pyx_obj_5_cdec_DenseVector *)__pyx_t_6);
+ __pyx_t_6 = 0;
+
+ /* "_cdec.pyx":59
+ * del config_stream
+ * self.weights = DenseVector.__new__(DenseVector)
+ * self.weights.vector = &self.dec.CurrentWeightVector() # <<<<<<<<<<<<<<
+ * self.weights.owned = True
+ *
+ */
+ __pyx_v_self->weights->vector = (&__pyx_v_self->dec->CurrentWeightVector());
+
+ /* "_cdec.pyx":60
+ * self.weights = DenseVector.__new__(DenseVector)
+ * self.weights.vector = &self.dec.CurrentWeightVector()
+ * self.weights.owned = True # <<<<<<<<<<<<<<
+ *
+ * def __dealloc__(self):
+ */
+ __pyx_v_self->weights->owned = 1;
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __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_r = -1;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_formalism);
+ __Pyx_XDECREF(__pyx_v_config_str);
+ __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
/* Python wrapper */
-static void __pyx_pw_5_cdec_7Lattice_7__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pw_5_cdec_7Lattice_7__dealloc__(PyObject *__pyx_v_self) {
+static void __pyx_pw_5_cdec_7Decoder_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_5_cdec_7Decoder_3__dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
- __pyx_pf_5_cdec_7Lattice_6__dealloc__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self));
+ __pyx_pf_5_cdec_7Decoder_2__dealloc__(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
}
-/* "_cdec.pyx":153
- * return iter(eval(str(self)))
+/* "_cdec.pyx":62
+ * self.weights.owned = True
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
- * del self.lattice
+ * del self.dec
*
*/
-static void __pyx_pf_5_cdec_7Lattice_6__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
+static void __pyx_pf_5_cdec_7Decoder_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Decoder *__pyx_v_self) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__", 0);
- /* "_cdec.pyx":154
+ /* "_cdec.pyx":63
*
* def __dealloc__(self):
- * del self.lattice # <<<<<<<<<<<<<<
+ * del self.dec # <<<<<<<<<<<<<<
*
- * # TODO: wrap SparseVector
+ * property weights:
*/
- delete __pyx_v_self->lattice;
+ delete __pyx_v_self->dec;
+
+ __Pyx_RefNannyFinishContext();
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_7Decoder_7weights_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_7Decoder_7weights_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_7Decoder_7weights___get__(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "_cdec.pyx":66
+ *
+ * property weights:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * return self.weights
+ *
+ */
+
+static PyObject *__pyx_pf_5_cdec_7Decoder_7weights___get__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__", 0);
+
+ /* "_cdec.pyx":67
+ * property weights:
+ * def __get__(self):
+ * return self.weights # <<<<<<<<<<<<<<
+ *
+ * def __set__(self, weights):
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_self->weights));
+ __pyx_r = ((PyObject *)__pyx_v_self->weights);
+ goto __pyx_L0;
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
+ return __pyx_r;
}
-static PyObject *__pyx_tp_new_5_cdec_Weights(PyTypeObject *t, PyObject *a, PyObject *k) {
+/* Python wrapper */
+static int __pyx_pw_5_cdec_7Decoder_7weights_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_weights); /*proto*/
+static int __pyx_pw_5_cdec_7Decoder_7weights_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_weights) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_7Decoder_7weights_2__set__(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self), ((PyObject *)__pyx_v_weights));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "_cdec.pyx":69
+ * return self.weights
+ *
+ * def __set__(self, weights): # <<<<<<<<<<<<<<
+ * if isinstance(weights, DenseVector):
+ * self.weights.vector[0] = (<DenseVector> weights).vector[0]
+ */
+
+static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_weights) {
+ PyObject *__pyx_v_fname = NULL;
+ PyObject *__pyx_v_fval = NULL;
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
+ Py_ssize_t __pyx_t_4;
+ PyObject *(*__pyx_t_5)(PyObject *);
+ PyObject *__pyx_t_6 = NULL;
+ PyObject *__pyx_t_7 = NULL;
+ PyObject *__pyx_t_8 = NULL;
+ PyObject *(*__pyx_t_9)(PyObject *);
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__set__", 0);
+
+ /* "_cdec.pyx":70
+ *
+ * def __set__(self, weights):
+ * if isinstance(weights, DenseVector): # <<<<<<<<<<<<<<
+ * self.weights.vector[0] = (<DenseVector> weights).vector[0]
+ * elif isinstance(weights, SparseVector):
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_DenseVector));
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_weights, __pyx_t_1);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ if (__pyx_t_2) {
+
+ /* "_cdec.pyx":71
+ * def __set__(self, weights):
+ * if isinstance(weights, DenseVector):
+ * self.weights.vector[0] = (<DenseVector> weights).vector[0] # <<<<<<<<<<<<<<
+ * elif isinstance(weights, SparseVector):
+ * self.weights.vector.clear()
+ */
+ (__pyx_v_self->weights->vector[0]) = (((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_weights)->vector[0]);
+ goto __pyx_L3;
+ }
+
+ /* "_cdec.pyx":72
+ * if isinstance(weights, DenseVector):
+ * self.weights.vector[0] = (<DenseVector> weights).vector[0]
+ * elif isinstance(weights, SparseVector): # <<<<<<<<<<<<<<
+ * self.weights.vector.clear()
+ * ((<SparseVector> weights).vector[0]).init_vector(self.weights.vector)
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector));
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_weights, __pyx_t_1);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ if (__pyx_t_2) {
+
+ /* "_cdec.pyx":73
+ * self.weights.vector[0] = (<DenseVector> weights).vector[0]
+ * elif isinstance(weights, SparseVector):
+ * self.weights.vector.clear() # <<<<<<<<<<<<<<
+ * ((<SparseVector> weights).vector[0]).init_vector(self.weights.vector)
+ * elif isinstance(weights, dict):
+ */
+ __pyx_v_self->weights->vector->clear();
+
+ /* "_cdec.pyx":74
+ * elif isinstance(weights, SparseVector):
+ * self.weights.vector.clear()
+ * ((<SparseVector> weights).vector[0]).init_vector(self.weights.vector) # <<<<<<<<<<<<<<
+ * elif isinstance(weights, dict):
+ * self.weights.vector.clear()
+ */
+ (((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_weights)->vector[0]).init_vector(__pyx_v_self->weights->vector);
+ goto __pyx_L3;
+ }
+
+ /* "_cdec.pyx":75
+ * self.weights.vector.clear()
+ * ((<SparseVector> weights).vector[0]).init_vector(self.weights.vector)
+ * elif isinstance(weights, dict): # <<<<<<<<<<<<<<
+ * self.weights.vector.clear()
+ * for fname, fval in weights.items():
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)(&PyDict_Type)));
+ __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_weights, __pyx_t_1);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ if (__pyx_t_2) {
+
+ /* "_cdec.pyx":76
+ * ((<SparseVector> weights).vector[0]).init_vector(self.weights.vector)
+ * elif isinstance(weights, dict):
+ * self.weights.vector.clear() # <<<<<<<<<<<<<<
+ * for fname, fval in weights.items():
+ * self.weights[fname] = fval
+ */
+ __pyx_v_self->weights->vector->clear();
+
+ /* "_cdec.pyx":77
+ * elif isinstance(weights, dict):
+ * self.weights.vector.clear()
+ * for fname, fval in weights.items(): # <<<<<<<<<<<<<<
+ * self.weights[fname] = fval
+ * else:
+ */
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_weights, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
+ __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
+ __pyx_t_5 = NULL;
+ } else {
+ __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext;
+ }
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ for (;;) {
+ if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
+ #else
+ __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
+ #else
+ __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #endif
+ } else {
+ __pyx_t_3 = __pyx_t_5(__pyx_t_1);
+ if (unlikely(!__pyx_t_3)) {
+ if (PyErr_Occurred()) {
+ if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
+ else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_3);
+ }
+ if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
+ PyObject* sequence = __pyx_t_3;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 2)) {
+ if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
+ if (likely(PyTuple_CheckExact(sequence))) {
+ __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
+ __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1);
+ } else {
+ __pyx_t_6 = PyList_GET_ITEM(sequence, 0);
+ __pyx_t_7 = PyList_GET_ITEM(sequence, 1);
+ }
+ __Pyx_INCREF(__pyx_t_6);
+ __Pyx_INCREF(__pyx_t_7);
+ #else
+ __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ #endif
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ } else
+ {
+ 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_GOTREF(__pyx_t_8);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
+ index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
+ __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;}
+ __pyx_t_9 = NULL;
+ __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+ goto __pyx_L7_unpacking_done;
+ __pyx_L6_unpacking_failed:;
+ __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+ __pyx_t_9 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_L7_unpacking_done:;
+ }
+ __Pyx_XDECREF(__pyx_v_fname);
+ __pyx_v_fname = __pyx_t_6;
+ __pyx_t_6 = 0;
+ __Pyx_XDECREF(__pyx_v_fval);
+ __pyx_v_fval = __pyx_t_7;
+ __pyx_t_7 = 0;
+
+ /* "_cdec.pyx":78
+ * self.weights.vector.clear()
+ * for fname, fval in weights.items():
+ * self.weights[fname] = fval # <<<<<<<<<<<<<<
+ * else:
+ * raise TypeError('cannot initialize weights with %s' % type(weights))
+ */
+ if (PyObject_SetItem(((PyObject *)__pyx_v_self->weights), __pyx_v_fname, __pyx_v_fval) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ goto __pyx_L3;
+ }
+ /*else*/ {
+
+ /* "_cdec.pyx":80
+ * self.weights[fname] = fval
+ * else:
+ * raise TypeError('cannot initialize weights with %s' % type(weights)) # <<<<<<<<<<<<<<
+ *
+ * property formalism:
+ */
+ __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_49), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+ __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ __pyx_L3:;
+
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_XDECREF(__pyx_t_7);
+ __Pyx_XDECREF(__pyx_t_8);
+ __Pyx_AddTraceback("_cdec.Decoder.weights.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_fname);
+ __Pyx_XDECREF(__pyx_v_fval);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_7Decoder_9formalism_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_7Decoder_9formalism_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_7Decoder_9formalism___get__(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "_cdec.pyx":83
+ *
+ * property formalism:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * cdef variables_map* conf = &self.dec.GetConf()
+ * return conf[0]['formalism'].as_str()
+ */
+
+static PyObject *__pyx_pf_5_cdec_7Decoder_9formalism___get__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self) {
+ const boost::program_options::variables_map *__pyx_v_conf;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__get__", 0);
+
+ /* "_cdec.pyx":84
+ * property formalism:
+ * def __get__(self):
+ * cdef variables_map* conf = &self.dec.GetConf() # <<<<<<<<<<<<<<
+ * return conf[0]['formalism'].as_str()
+ *
+ */
+ __pyx_v_conf = (&__pyx_v_self->dec->GetConf());
+
+ /* "_cdec.pyx":85
+ * def __get__(self):
+ * cdef variables_map* conf = &self.dec.GetConf()
+ * return conf[0]['formalism'].as_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_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_r = ((PyObject *)__pyx_t_1);
+ __pyx_t_1 = 0;
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("_cdec.Decoder.formalism.__get__", __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_7Decoder_5read_weights(PyObject *__pyx_v_self, PyObject *__pyx_v_weights); /*proto*/
+static PyObject *__pyx_pw_5_cdec_7Decoder_5read_weights(PyObject *__pyx_v_self, PyObject *__pyx_v_weights) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("read_weights (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_7Decoder_4read_weights(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self), ((PyObject *)__pyx_v_weights));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "_cdec.pyx":87
+ * return conf[0]['formalism'].as_str()
+ *
+ * def read_weights(self, weights): # <<<<<<<<<<<<<<
+ * 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) {
+ PyObject *__pyx_v_fp = NULL;
+ PyObject *__pyx_v_line = NULL;
+ PyObject *__pyx_v_fname = NULL;
+ PyObject *__pyx_v_value = NULL;
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ PyObject *__pyx_t_4 = NULL;
+ PyObject *__pyx_t_5 = NULL;
+ PyObject *__pyx_t_6 = NULL;
+ PyObject *__pyx_t_7 = NULL;
+ Py_ssize_t __pyx_t_8;
+ PyObject *(*__pyx_t_9)(PyObject *);
+ int __pyx_t_10;
+ PyObject *__pyx_t_11 = NULL;
+ PyObject *__pyx_t_12 = NULL;
+ PyObject *(*__pyx_t_13)(PyObject *);
+ double __pyx_t_14;
+ PyObject *__pyx_t_15 = NULL;
+ int __pyx_t_16;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("read_weights", 0);
+
+ /* "_cdec.pyx":88
+ *
+ * def read_weights(self, weights):
+ * 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_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_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_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_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_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ /*try:*/ {
+ {
+ __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
+ __Pyx_XGOTREF(__pyx_t_5);
+ __Pyx_XGOTREF(__pyx_t_6);
+ __Pyx_XGOTREF(__pyx_t_7);
+ /*try:*/ {
+ __Pyx_INCREF(__pyx_t_4);
+ __pyx_v_fp = __pyx_t_4;
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+ /* "_cdec.pyx":89
+ * def read_weights(self, weights):
+ * with open(weights) as fp:
+ * for line in fp: # <<<<<<<<<<<<<<
+ * if line.strip().startswith('#'): continue
+ * fname, value = line.split()
+ */
+ if (PyList_CheckExact(__pyx_v_fp) || PyTuple_CheckExact(__pyx_v_fp)) {
+ __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_GOTREF(__pyx_t_4);
+ __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext;
+ }
+ for (;;) {
+ if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_4)) {
+ if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;};
+ #endif
+ } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_4)) {
+ if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++;
+ #else
+ __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;};
+ #endif
+ } else {
+ __pyx_t_2 = __pyx_t_9(__pyx_t_4);
+ if (unlikely(!__pyx_t_2)) {
+ if (PyErr_Occurred()) {
+ if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
+ else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ }
+ break;
+ }
+ __Pyx_GOTREF(__pyx_t_2);
+ }
+ __Pyx_XDECREF(__pyx_v_line);
+ __pyx_v_line = __pyx_t_2;
+ __pyx_t_2 = 0;
+
+ /* "_cdec.pyx":90
+ * with open(weights) as fp:
+ * for line in fp:
+ * if line.strip().startswith('#'): continue # <<<<<<<<<<<<<<
+ * fname, value = line.split()
+ * self.weights[fname.strip()] = float(value)
+ */
+ __pyx_t_2 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__strip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__startswith); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_51), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ if (__pyx_t_10) {
+ goto __pyx_L16_continue;
+ goto __pyx_L18;
+ }
+ __pyx_L18:;
+
+ /* "_cdec.pyx":91
+ * for line in fp:
+ * if line.strip().startswith('#'): continue
+ * fname, value = line.split() # <<<<<<<<<<<<<<
+ * self.weights[fname.strip()] = float(value)
+ *
+ */
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
+ PyObject* sequence = __pyx_t_2;
+ #if CYTHON_COMPILING_IN_CPYTHON
+ Py_ssize_t size = Py_SIZE(sequence);
+ #else
+ Py_ssize_t size = PySequence_Size(sequence);
+ #endif
+ if (unlikely(size != 2)) {
+ if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+ else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ }
+ #if CYTHON_COMPILING_IN_CPYTHON
+ if (likely(PyTuple_CheckExact(sequence))) {
+ __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0);
+ __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1);
+ } else {
+ __pyx_t_1 = PyList_GET_ITEM(sequence, 0);
+ __pyx_t_11 = PyList_GET_ITEM(sequence, 1);
+ }
+ __Pyx_INCREF(__pyx_t_1);
+ __Pyx_INCREF(__pyx_t_11);
+ #else
+ __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ #endif
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ } else
+ {
+ 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_GOTREF(__pyx_t_12);
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
+ index = 0; __pyx_t_1 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_1)) goto __pyx_L19_unpacking_failed;
+ __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;}
+ __pyx_t_13 = NULL;
+ __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+ goto __pyx_L20_unpacking_done;
+ __pyx_L19_unpacking_failed:;
+ __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+ __pyx_t_13 = NULL;
+ if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_L20_unpacking_done:;
+ }
+ __Pyx_XDECREF(__pyx_v_fname);
+ __pyx_v_fname = __pyx_t_1;
+ __pyx_t_1 = 0;
+ __Pyx_XDECREF(__pyx_v_value);
+ __pyx_v_value = __pyx_t_11;
+ __pyx_t_11 = 0;
+
+ /* "_cdec.pyx":92
+ * if line.strip().startswith('#'): continue
+ * fname, value = line.split()
+ * self.weights[fname.strip()] = float(value) # <<<<<<<<<<<<<<
+ *
+ * def translate(self, sentence, grammar=None):
+ */
+ __pyx_t_14 = __Pyx_PyObject_AsDouble(__pyx_v_value); if (unlikely(__pyx_t_14 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_2 = PyFloat_FromDouble(__pyx_t_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __pyx_t_11 = PyObject_GetAttr(__pyx_v_fname, __pyx_n_s__strip); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __Pyx_GOTREF(__pyx_t_11);
+ __pyx_t_1 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+ if (PyObject_SetItem(((PyObject *)__pyx_v_self->weights), __pyx_t_1, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ __pyx_L16_continue:;
+ }
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ }
+ __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
+ goto __pyx_L14_try_end;
+ __pyx_L7_error:;
+ __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
+ __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
+ __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+ __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+ /* "_cdec.pyx":88
+ *
+ * def read_weights(self, weights):
+ * 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;}
+ __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_GOTREF(__pyx_t_11);
+ __Pyx_INCREF(__pyx_t_4);
+ PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4);
+ __Pyx_GIVEREF(__pyx_t_4);
+ __Pyx_INCREF(__pyx_t_2);
+ PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_2);
+ __Pyx_GIVEREF(__pyx_t_2);
+ __Pyx_INCREF(__pyx_t_1);
+ PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_1);
+ __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;}
+ __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;}
+ __pyx_t_16 = (!__pyx_t_10);
+ if (__pyx_t_16) {
+ __Pyx_GIVEREF(__pyx_t_4);
+ __Pyx_GIVEREF(__pyx_t_2);
+ __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;}
+ goto __pyx_L23;
+ }
+ __pyx_L23:;
+ __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ goto __pyx_L8_exception_handled;
+ }
+ __pyx_L9_except_error:;
+ __Pyx_XGIVEREF(__pyx_t_5);
+ __Pyx_XGIVEREF(__pyx_t_6);
+ __Pyx_XGIVEREF(__pyx_t_7);
+ __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
+ goto __pyx_L1_error;
+ __pyx_L8_exception_handled:;
+ __Pyx_XGIVEREF(__pyx_t_5);
+ __Pyx_XGIVEREF(__pyx_t_6);
+ __Pyx_XGIVEREF(__pyx_t_7);
+ __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
+ __pyx_L14_try_end:;
+ }
+ }
+ /*finally:*/ {
+ if (__pyx_t_3) {
+ __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_52, NULL);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_7);
+ __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_7);
+ __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+ if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ }
+ goto __pyx_L24;
+ __pyx_L3_error:;
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ goto __pyx_L1_error;
+ __pyx_L24:;
+ }
+
+ __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_XDECREF(__pyx_t_4);
+ __Pyx_XDECREF(__pyx_t_11);
+ __Pyx_XDECREF(__pyx_t_12);
+ __Pyx_AddTraceback("_cdec.Decoder.read_weights", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_fp);
+ __Pyx_XDECREF(__pyx_v_line);
+ __Pyx_XDECREF(__pyx_v_fname);
+ __Pyx_XDECREF(__pyx_v_value);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+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;
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("translate (wrapper)", 0);
+ {
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__sentence,&__pyx_n_s__grammar,0};
+ PyObject* values[2] = {0,0};
+
+ /* "_cdec.pyx":94
+ * self.weights[fname.strip()] = float(value)
+ *
+ * def translate(self, sentence, grammar=None): # <<<<<<<<<<<<<<
+ * cdef bytes input_str
+ * if isinstance(sentence, unicode) or isinstance(sentence, str):
+ */
+ values[1] = ((PyObject *)Py_None);
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args;
+ const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+ switch (pos_args) {
+ case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ kw_args = PyDict_Size(__pyx_kwds);
+ switch (pos_args) {
+ case 0:
+ if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sentence)) != 0)) kw_args--;
+ else goto __pyx_L5_argtuple_error;
+ case 1:
+ if (kw_args > 0) {
+ PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grammar);
+ if (value) { values[1] = value; kw_args--; }
+ }
+ }
+ 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;}
+ }
+ } else {
+ switch (PyTuple_GET_SIZE(__pyx_args)) {
+ case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ }
+ __pyx_v_sentence = values[0];
+ __pyx_v_grammar = values[1];
+ }
+ 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_L3_error:;
+ __Pyx_AddTraceback("_cdec.Decoder.translate", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5_cdec_7Decoder_6translate(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self), __pyx_v_sentence, __pyx_v_grammar);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_sentence, PyObject *__pyx_v_grammar) {
+ PyObject *__pyx_v_input_str = 0;
+ BasicObserver __pyx_v_observer;
+ struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_hg = 0;
+ PyObject *__pyx_r = NULL;
+ __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;
+ 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):
+ * cdef bytes input_str
+ * if isinstance(sentence, unicode) or isinstance(sentence, str): # <<<<<<<<<<<<<<
+ * input_str = as_str(sentence.strip())
+ * elif isinstance(sentence, Lattice):
+ */
+ __pyx_t_1 = ((PyObject *)((PyObject*)(&PyUnicode_Type)));
+ __Pyx_INCREF(__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_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) {
+
+ /* "_cdec.pyx":97
+ * cdef bytes input_str
+ * if isinstance(sentence, unicode) or isinstance(sentence, str):
+ * input_str = as_str(sentence.strip()) # <<<<<<<<<<<<<<
+ * elif isinstance(sentence, Lattice):
+ * input_str = str(sentence) # PLF format
+ */
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_t_1 = PyBytes_FromString(__pyx_f_5_cdec_as_str(__pyx_t_5, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 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 = 0;
+ goto __pyx_L3;
+ }
+
+ /* "_cdec.pyx":98
+ * if isinstance(sentence, unicode) or isinstance(sentence, str):
+ * input_str = as_str(sentence.strip())
+ * elif isinstance(sentence, Lattice): # <<<<<<<<<<<<<<
+ * input_str = str(sentence) # PLF format
+ * else:
+ */
+ __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_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ if (__pyx_t_4) {
+
+ /* "_cdec.pyx":99
+ * input_str = as_str(sentence.strip())
+ * elif isinstance(sentence, Lattice):
+ * input_str = str(sentence) # PLF format # <<<<<<<<<<<<<<
+ * else:
+ * raise TypeError('Cannot translate input type %s' % type(sentence))
+ */
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_INCREF(__pyx_v_sentence);
+ PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sentence);
+ __Pyx_GIVEREF(__pyx_v_sentence);
+ __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+ if (!(likely(PyBytes_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_input_str = ((PyObject*)__pyx_t_5);
+ __pyx_t_5 = 0;
+ goto __pyx_L3;
+ }
+ /*else*/ {
+
+ /* "_cdec.pyx":101
+ * input_str = str(sentence) # PLF format
+ * else:
+ * raise TypeError('Cannot translate input type %s' % type(sentence)) # <<<<<<<<<<<<<<
+ * if grammar:
+ * if isinstance(grammar, str) or isinstance(grammar, unicode):
+ */
+ __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_53), ((PyObject *)Py_TYPE(__pyx_v_sentence))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 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_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);
+ __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_L3:;
+
+ /* "_cdec.pyx":102
+ * else:
+ * raise TypeError('Cannot translate input type %s' % type(sentence))
+ * if grammar: # <<<<<<<<<<<<<<
+ * if isinstance(grammar, str) or isinstance(grammar, unicode):
+ * self.dec.AddSupplementalGrammarFromString(string(as_str(grammar)))
+ */
+ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_grammar); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__pyx_t_4) {
+
+ /* "_cdec.pyx":103
+ * 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)))
+ * 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) {
+
+ /* "_cdec.pyx":104
+ * if grammar:
+ * if isinstance(grammar, str) or isinstance(grammar, unicode):
+ * self.dec.AddSupplementalGrammarFromString(string(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)));
+ goto __pyx_L5;
+ }
+ /*else*/ {
+
+ /* "_cdec.pyx":106
+ * self.dec.AddSupplementalGrammarFromString(string(as_str(grammar)))
+ * else:
+ * self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0]) # <<<<<<<<<<<<<<
+ * cdef decoder.BasicObserver observer = decoder.BasicObserver()
+ * self.dec.Decode(string(input_str), &observer)
+ */
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_INCREF(__pyx_v_grammar);
+ PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_grammar);
+ __Pyx_GIVEREF(__pyx_v_grammar);
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TextGrammar)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ __pyx_v_self->dec->AddSupplementalGrammar((((struct __pyx_obj_5_cdec_TextGrammar *)__pyx_t_1)->__pyx_base.grammar[0]));
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ }
+ __pyx_L5:;
+ goto __pyx_L4;
+ }
+ __pyx_L4:;
+
+ /* "_cdec.pyx":107
+ * else:
+ * self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0])
+ * cdef decoder.BasicObserver observer = decoder.BasicObserver() # <<<<<<<<<<<<<<
+ * self.dec.Decode(string(input_str), &observer)
+ * if observer.hypergraph == NULL:
+ */
+ __pyx_v_observer = BasicObserver();
+
+ /* "_cdec.pyx":108
+ * self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0])
+ * cdef decoder.BasicObserver observer = decoder.BasicObserver()
+ * self.dec.Decode(string(input_str), &observer) # <<<<<<<<<<<<<<
+ * if observer.hypergraph == NULL:
+ * raise ParseFailed()
+ */
+ __pyx_t_6 = PyBytes_AsString(((PyObject *)__pyx_v_input_str)); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_self->dec->Decode(std::string(__pyx_t_6), (&__pyx_v_observer));
+
+ /* "_cdec.pyx":109
+ * cdef decoder.BasicObserver observer = decoder.BasicObserver()
+ * self.dec.Decode(string(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) {
+
+ /* "_cdec.pyx":110
+ * self.dec.Decode(string(input_str), &observer)
+ * if observer.hypergraph == NULL:
+ * raise ParseFailed() # <<<<<<<<<<<<<<
+ * cdef Hypergraph hg = Hypergraph()
+ * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0])
+ */
+ __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ParseFailed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_Raise(__pyx_t_5, 0, 0, 0);
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ goto __pyx_L6;
+ }
+ __pyx_L6:;
+
+ /* "_cdec.pyx":111
+ * if observer.hypergraph == NULL:
+ * raise ParseFailed()
+ * cdef Hypergraph hg = Hypergraph() # <<<<<<<<<<<<<<
+ * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0])
+ * return hg
+ */
+ __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Hypergraph)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_v_hg = ((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_t_5);
+ __pyx_t_5 = 0;
+
+ /* "_cdec.pyx":112
+ * raise ParseFailed()
+ * cdef Hypergraph hg = Hypergraph()
+ * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0]) # <<<<<<<<<<<<<<
+ * return hg
+ */
+ __pyx_v_hg->hg = new Hypergraph((__pyx_v_observer.hypergraph[0]));
+
+ /* "_cdec.pyx":113
+ * cdef Hypergraph hg = Hypergraph()
+ * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0])
+ * return hg # <<<<<<<<<<<<<<
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __Pyx_INCREF(((PyObject *)__pyx_v_hg));
+ __pyx_r = ((PyObject *)__pyx_v_hg);
+ 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_5);
+ __Pyx_AddTraceback("_cdec.Decoder.translate", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XDECREF(__pyx_v_input_str);
+ __Pyx_XDECREF((PyObject *)__pyx_v_hg);
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "string.to_py":25
+ *
+ * @cname("__pyx_convert_string_to_py_")
+ * cdef object __pyx_convert_string_to_py_(string& s): # <<<<<<<<<<<<<<
+ * return s.data()[:s.size()]
+ *
+ */
+
+static PyObject *__pyx_convert_string_to_py_(const std::string &__pyx_v_s) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__pyx_convert_string_to_py_", 0);
+
+ /* "string.to_py":26
+ * @cname("__pyx_convert_string_to_py_")
+ * cdef object __pyx_convert_string_to_py_(string& s):
+ * return s.data()[:s.size()] # <<<<<<<<<<<<<<
+ *
+ *
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __pyx_t_1 = PyBytes_FromStringAndSize(__pyx_v_s.data() + 0, __pyx_v_s.size() - 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+ __pyx_r = ((PyObject *)__pyx_t_1);
+ __pyx_t_1 = 0;
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("string.to_py.__pyx_convert_string_to_py_", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = 0;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static PyObject *__pyx_tp_new_5_cdec_DenseVector(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
- if (__pyx_pw_5_cdec_7Weights_1__cinit__(o, a, k) < 0) {
- Py_DECREF(o); o = 0;
- }
return o;
}
-static void __pyx_tp_dealloc_5_cdec_Weights(PyObject *o) {
+static void __pyx_tp_dealloc_5_cdec_DenseVector(PyObject *o) {
+ {
+ PyObject *etype, *eval, *etb;
+ PyErr_Fetch(&etype, &eval, &etb);
+ ++Py_REFCNT(o);
+ __pyx_pw_5_cdec_11DenseVector_3__dealloc__(o);
+ if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+ --Py_REFCNT(o);
+ PyErr_Restore(etype, eval, etb);
+ }
(*Py_TYPE(o)->tp_free)(o);
}
-static PyObject *__pyx_sq_item_5_cdec_Weights(PyObject *o, Py_ssize_t i) {
+static PyObject *__pyx_sq_item_5_cdec_DenseVector(PyObject *o, Py_ssize_t i) {
PyObject *r;
PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
@@ -3263,9 +18696,9 @@ static PyObject *__pyx_sq_item_5_cdec_Weights(PyObject *o, Py_ssize_t i) {
return r;
}
-static int __pyx_mp_ass_subscript_5_cdec_Weights(PyObject *o, PyObject *i, PyObject *v) {
+static int __pyx_mp_ass_subscript_5_cdec_DenseVector(PyObject *o, PyObject *i, PyObject *v) {
if (v) {
- return __pyx_pw_5_cdec_7Weights_5__setitem__(o, i, v);
+ return __pyx_pw_5_cdec_11DenseVector_9__setitem__(o, i, v);
}
else {
PyErr_Format(PyExc_NotImplementedError,
@@ -3274,11 +18707,13 @@ static int __pyx_mp_ass_subscript_5_cdec_Weights(PyObject *o, PyObject *i, PyObj
}
}
-static PyMethodDef __pyx_methods_5_cdec_Weights[] = {
+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)},
{0, 0, 0, 0}
};
-static PyNumberMethods __pyx_tp_as_number_Weights = {
+static PyNumberMethods __pyx_tp_as_number_DenseVector = {
0, /*nb_add*/
0, /*nb_subtract*/
0, /*nb_multiply*/
@@ -3336,11 +18771,11 @@ static PyNumberMethods __pyx_tp_as_number_Weights = {
#endif
};
-static PySequenceMethods __pyx_tp_as_sequence_Weights = {
- 0, /*sq_length*/
+static PySequenceMethods __pyx_tp_as_sequence_DenseVector = {
+ __pyx_pw_5_cdec_11DenseVector_5__len__, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
- __pyx_sq_item_5_cdec_Weights, /*sq_item*/
+ __pyx_sq_item_5_cdec_DenseVector, /*sq_item*/
0, /*sq_slice*/
0, /*sq_ass_item*/
0, /*sq_ass_slice*/
@@ -3349,13 +18784,13 @@ static PySequenceMethods __pyx_tp_as_sequence_Weights = {
0, /*sq_inplace_repeat*/
};
-static PyMappingMethods __pyx_tp_as_mapping_Weights = {
- 0, /*mp_length*/
- __pyx_pw_5_cdec_7Weights_3__getitem__, /*mp_subscript*/
- __pyx_mp_ass_subscript_5_cdec_Weights, /*mp_ass_subscript*/
+static PyMappingMethods __pyx_tp_as_mapping_DenseVector = {
+ __pyx_pw_5_cdec_11DenseVector_5__len__, /*mp_length*/
+ __pyx_pw_5_cdec_11DenseVector_7__getitem__, /*mp_subscript*/
+ __pyx_mp_ass_subscript_5_cdec_DenseVector, /*mp_ass_subscript*/
};
-static PyBufferProcs __pyx_tp_as_buffer_Weights = {
+static PyBufferProcs __pyx_tp_as_buffer_DenseVector = {
#if PY_MAJOR_VERSION < 3
0, /*bf_getreadbuffer*/
#endif
@@ -3376,12 +18811,12 @@ static PyBufferProcs __pyx_tp_as_buffer_Weights = {
#endif
};
-static PyTypeObject __pyx_type_5_cdec_Weights = {
+static PyTypeObject __pyx_type_5_cdec_DenseVector = {
PyVarObject_HEAD_INIT(0, 0)
- __Pyx_NAMESTR("_cdec.Weights"), /*tp_name*/
- sizeof(struct __pyx_obj_5_cdec_Weights), /*tp_basicsize*/
+ __Pyx_NAMESTR("_cdec.DenseVector"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_DenseVector), /*tp_basicsize*/
0, /*tp_itemsize*/
- __pyx_tp_dealloc_5_cdec_Weights, /*tp_dealloc*/
+ __pyx_tp_dealloc_5_cdec_DenseVector, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
@@ -3391,24 +18826,24 @@ static PyTypeObject __pyx_type_5_cdec_Weights = {
0, /*reserved*/
#endif
0, /*tp_repr*/
- &__pyx_tp_as_number_Weights, /*tp_as_number*/
- &__pyx_tp_as_sequence_Weights, /*tp_as_sequence*/
- &__pyx_tp_as_mapping_Weights, /*tp_as_mapping*/
+ &__pyx_tp_as_number_DenseVector, /*tp_as_number*/
+ &__pyx_tp_as_sequence_DenseVector, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_DenseVector, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
- &__pyx_tp_as_buffer_Weights, /*tp_as_buffer*/
+ &__pyx_tp_as_buffer_DenseVector, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
- __pyx_pw_5_cdec_7Weights_7__iter__, /*tp_iter*/
+ __pyx_pw_5_cdec_11DenseVector_11__iter__, /*tp_iter*/
0, /*tp_iternext*/
- __pyx_methods_5_cdec_Weights, /*tp_methods*/
+ __pyx_methods_5_cdec_DenseVector, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
0, /*tp_base*/
@@ -3416,9 +18851,9 @@ static PyTypeObject __pyx_type_5_cdec_Weights = {
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
- 0, /*tp_init*/
+ __pyx_pw_5_cdec_11DenseVector_1__init__, /*tp_init*/
0, /*tp_alloc*/
- __pyx_tp_new_5_cdec_Weights, /*tp_new*/
+ __pyx_tp_new_5_cdec_DenseVector, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
@@ -3432,76 +18867,274 @@ static PyTypeObject __pyx_type_5_cdec_Weights = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec_Decoder(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_5_cdec_Decoder *p;
+static PyObject *__pyx_tp_new_5_cdec_SparseVector(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
- p = ((struct __pyx_obj_5_cdec_Decoder *)o);
- p->weights = ((struct __pyx_obj_5_cdec_Weights *)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;
}
-static void __pyx_tp_dealloc_5_cdec_Decoder(PyObject *o) {
- struct __pyx_obj_5_cdec_Decoder *p = (struct __pyx_obj_5_cdec_Decoder *)o;
+static void __pyx_tp_dealloc_5_cdec_SparseVector(PyObject *o) {
{
PyObject *etype, *eval, *etb;
PyErr_Fetch(&etype, &eval, &etb);
++Py_REFCNT(o);
- __pyx_pw_5_cdec_7Decoder_3__dealloc__(o);
+ __pyx_pw_5_cdec_12SparseVector_3__dealloc__(o);
if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
--Py_REFCNT(o);
PyErr_Restore(etype, eval, etb);
}
- Py_XDECREF(((PyObject *)p->weights));
(*Py_TYPE(o)->tp_free)(o);
}
+static PyObject *__pyx_sq_item_5_cdec_SparseVector(PyObject *o, Py_ssize_t i) {
+ PyObject *r;
+ PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
+ r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
+ Py_DECREF(x);
+ return r;
+}
-static int __pyx_tp_traverse_5_cdec_Decoder(PyObject *o, visitproc v, void *a) {
+static int __pyx_mp_ass_subscript_5_cdec_SparseVector(PyObject *o, PyObject *i, PyObject *v) {
+ if (v) {
+ return __pyx_pw_5_cdec_12SparseVector_9__setitem__(o, i, v);
+ }
+ else {
+ PyErr_Format(PyExc_NotImplementedError,
+ "Subscript deletion not supported by %s", Py_TYPE(o)->tp_name);
+ return -1;
+ }
+}
+
+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)},
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_SparseVector = {
+ __pyx_pw_5_cdec_12SparseVector_32__add__, /*nb_add*/
+ __pyx_pw_5_cdec_12SparseVector_34__sub__, /*nb_subtract*/
+ __pyx_pw_5_cdec_12SparseVector_36__mul__, /*nb_multiply*/
+ #if PY_MAJOR_VERSION < 3
+ __pyx_pw_5_cdec_12SparseVector_38__div__, /*nb_divide*/
+ #endif
+ 0, /*nb_remainder*/
+ 0, /*nb_divmod*/
+ 0, /*nb_power*/
+ __pyx_pw_5_cdec_12SparseVector_22__neg__, /*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
+ __pyx_pw_5_cdec_12SparseVector_24__iadd__, /*nb_inplace_add*/
+ __pyx_pw_5_cdec_12SparseVector_26__isub__, /*nb_inplace_subtract*/
+ __pyx_pw_5_cdec_12SparseVector_28__imul__, /*nb_inplace_multiply*/
+ #if PY_MAJOR_VERSION < 3
+ __pyx_pw_5_cdec_12SparseVector_30__idiv__, /*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_SparseVector = {
+ __pyx_pw_5_cdec_12SparseVector_18__len__, /*sq_length*/
+ 0, /*sq_concat*/
+ 0, /*sq_repeat*/
+ __pyx_sq_item_5_cdec_SparseVector, /*sq_item*/
+ 0, /*sq_slice*/
+ 0, /*sq_ass_item*/
+ 0, /*sq_ass_slice*/
+ __pyx_pw_5_cdec_12SparseVector_20__contains__, /*sq_contains*/
+ 0, /*sq_inplace_concat*/
+ 0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_SparseVector = {
+ __pyx_pw_5_cdec_12SparseVector_18__len__, /*mp_length*/
+ __pyx_pw_5_cdec_12SparseVector_7__getitem__, /*mp_subscript*/
+ __pyx_mp_ass_subscript_5_cdec_SparseVector, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_SparseVector = {
+ #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_SparseVector = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.SparseVector"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_SparseVector), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_SparseVector, /*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_SparseVector, /*tp_as_number*/
+ &__pyx_tp_as_sequence_SparseVector, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_SparseVector, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_SparseVector, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ __pyx_pw_5_cdec_12SparseVector_16__richcmp__, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ __pyx_pw_5_cdec_12SparseVector_11__iter__, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_SparseVector, /*tp_methods*/
+ 0, /*tp_members*/
+ 0, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ __pyx_pw_5_cdec_12SparseVector_1__init__, /*tp_init*/
+ 0, /*tp_alloc*/
+ __pyx_tp_new_5_cdec_SparseVector, /*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_NT(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec_NT *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec_NT *)o);
+ p->cat = ((PyObject*)Py_None); Py_INCREF(Py_None);
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec_NT(PyObject *o, visitproc v, void *a) {
int e;
- struct __pyx_obj_5_cdec_Decoder *p = (struct __pyx_obj_5_cdec_Decoder *)o;
- if (p->weights) {
- e = (*v)(((PyObject*)p->weights), a); if (e) return e;
+ struct __pyx_obj_5_cdec_NT *p = (struct __pyx_obj_5_cdec_NT *)o;
+ if (p->cat) {
+ e = (*v)(p->cat, a); if (e) return e;
}
return 0;
}
-static int __pyx_tp_clear_5_cdec_Decoder(PyObject *o) {
- struct __pyx_obj_5_cdec_Decoder *p = (struct __pyx_obj_5_cdec_Decoder *)o;
+static int __pyx_tp_clear_5_cdec_NT(PyObject *o) {
+ struct __pyx_obj_5_cdec_NT *p = (struct __pyx_obj_5_cdec_NT *)o;
PyObject* tmp;
- tmp = ((PyObject*)p->weights);
- p->weights = ((struct __pyx_obj_5_cdec_Weights *)Py_None); Py_INCREF(Py_None);
+ tmp = ((PyObject*)p->cat);
+ p->cat = ((PyObject*)Py_None); Py_INCREF(Py_None);
Py_XDECREF(tmp);
return 0;
}
-static PyObject *__pyx_getprop_5_cdec_7Decoder_weights(PyObject *o, void *x) {
- return __pyx_pw_5_cdec_7Decoder_7weights_1__get__(o);
+static PyObject *__pyx_getprop_5_cdec_2NT_cat(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_2NT_3cat_1__get__(o);
}
-static int __pyx_setprop_5_cdec_7Decoder_weights(PyObject *o, PyObject *v, void *x) {
+static int __pyx_setprop_5_cdec_2NT_cat(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
if (v) {
- return __pyx_pw_5_cdec_7Decoder_7weights_3__set__(o, v);
+ return __pyx_pw_5_cdec_2NT_3cat_3__set__(o, v);
}
else {
- return __pyx_pw_5_cdec_7Decoder_7weights_5__del__(o);
+ return __pyx_pw_5_cdec_2NT_3cat_5__del__(o);
}
}
-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)},
+static PyObject *__pyx_getprop_5_cdec_2NT_ref(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_2NT_3ref_1__get__(o);
+}
+
+static int __pyx_setprop_5_cdec_2NT_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+ if (v) {
+ return __pyx_pw_5_cdec_2NT_3ref_3__set__(o, v);
+ }
+ else {
+ PyErr_SetString(PyExc_NotImplementedError, "__del__");
+ return -1;
+ }
+}
+
+static PyMethodDef __pyx_methods_5_cdec_NT[] = {
{0, 0, 0, 0}
};
-static struct PyGetSetDef __pyx_getsets_5_cdec_Decoder[] = {
- {(char *)"weights", __pyx_getprop_5_cdec_7Decoder_weights, __pyx_setprop_5_cdec_7Decoder_weights, 0, 0},
+static struct PyGetSetDef __pyx_getsets_5_cdec_NT[] = {
+ {(char *)"cat", __pyx_getprop_5_cdec_2NT_cat, __pyx_setprop_5_cdec_2NT_cat, 0, 0},
+ {(char *)"ref", __pyx_getprop_5_cdec_2NT_ref, __pyx_setprop_5_cdec_2NT_ref, 0, 0},
{0, 0, 0, 0, 0}
};
-static PyNumberMethods __pyx_tp_as_number_Decoder = {
+static PyNumberMethods __pyx_tp_as_number_NT = {
0, /*nb_add*/
0, /*nb_subtract*/
0, /*nb_multiply*/
@@ -3559,7 +19192,7 @@ static PyNumberMethods __pyx_tp_as_number_Decoder = {
#endif
};
-static PySequenceMethods __pyx_tp_as_sequence_Decoder = {
+static PySequenceMethods __pyx_tp_as_sequence_NT = {
0, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
@@ -3572,13 +19205,13 @@ static PySequenceMethods __pyx_tp_as_sequence_Decoder = {
0, /*sq_inplace_repeat*/
};
-static PyMappingMethods __pyx_tp_as_mapping_Decoder = {
+static PyMappingMethods __pyx_tp_as_mapping_NT = {
0, /*mp_length*/
0, /*mp_subscript*/
0, /*mp_ass_subscript*/
};
-static PyBufferProcs __pyx_tp_as_buffer_Decoder = {
+static PyBufferProcs __pyx_tp_as_buffer_NT = {
#if PY_MAJOR_VERSION < 3
0, /*bf_getreadbuffer*/
#endif
@@ -3599,12 +19232,12 @@ static PyBufferProcs __pyx_tp_as_buffer_Decoder = {
#endif
};
-static PyTypeObject __pyx_type_5_cdec_Decoder = {
+static PyTypeObject __pyx_type_5_cdec_NT = {
PyVarObject_HEAD_INIT(0, 0)
- __Pyx_NAMESTR("_cdec.Decoder"), /*tp_name*/
- sizeof(struct __pyx_obj_5_cdec_Decoder), /*tp_basicsize*/
+ __Pyx_NAMESTR("_cdec.NT"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_NT), /*tp_basicsize*/
0, /*tp_itemsize*/
- __pyx_tp_dealloc_5_cdec_Decoder, /*tp_dealloc*/
+ __pyx_tp_dealloc_5_cdec_NT, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
@@ -3614,26 +19247,838 @@ static PyTypeObject __pyx_type_5_cdec_Decoder = {
0, /*reserved*/
#endif
0, /*tp_repr*/
- &__pyx_tp_as_number_Decoder, /*tp_as_number*/
- &__pyx_tp_as_sequence_Decoder, /*tp_as_sequence*/
- &__pyx_tp_as_mapping_Decoder, /*tp_as_mapping*/
+ &__pyx_tp_as_number_NT, /*tp_as_number*/
+ &__pyx_tp_as_sequence_NT, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_NT, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
- 0, /*tp_str*/
+ __pyx_pw_5_cdec_2NT_3__str__, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
- &__pyx_tp_as_buffer_Decoder, /*tp_as_buffer*/
+ &__pyx_tp_as_buffer_NT, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
0, /*tp_doc*/
- __pyx_tp_traverse_5_cdec_Decoder, /*tp_traverse*/
- __pyx_tp_clear_5_cdec_Decoder, /*tp_clear*/
+ __pyx_tp_traverse_5_cdec_NT, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec_NT, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
- __pyx_methods_5_cdec_Decoder, /*tp_methods*/
+ __pyx_methods_5_cdec_NT, /*tp_methods*/
0, /*tp_members*/
- __pyx_getsets_5_cdec_Decoder, /*tp_getset*/
+ __pyx_getsets_5_cdec_NT, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ __pyx_pw_5_cdec_2NT_1__init__, /*tp_init*/
+ 0, /*tp_alloc*/
+ __pyx_tp_new_5_cdec_NT, /*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_NTRef(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ return o;
+}
+
+static void __pyx_tp_dealloc_5_cdec_NTRef(PyObject *o) {
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_5NTRef_ref(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_5NTRef_3ref_1__get__(o);
+}
+
+static int __pyx_setprop_5_cdec_5NTRef_ref(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+ if (v) {
+ return __pyx_pw_5_cdec_5NTRef_3ref_3__set__(o, v);
+ }
+ else {
+ PyErr_SetString(PyExc_NotImplementedError, "__del__");
+ return -1;
+ }
+}
+
+static PyMethodDef __pyx_methods_5_cdec_NTRef[] = {
+ {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_5_cdec_NTRef[] = {
+ {(char *)"ref", __pyx_getprop_5_cdec_5NTRef_ref, __pyx_setprop_5_cdec_5NTRef_ref, 0, 0},
+ {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_NTRef = {
+ 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_NTRef = {
+ 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_NTRef = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_NTRef = {
+ #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_NTRef = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.NTRef"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_NTRef), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_NTRef, /*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_NTRef, /*tp_as_number*/
+ &__pyx_tp_as_sequence_NTRef, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_NTRef, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ __pyx_pw_5_cdec_5NTRef_3__str__, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_NTRef, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_NTRef, /*tp_methods*/
+ 0, /*tp_members*/
+ __pyx_getsets_5_cdec_NTRef, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ __pyx_pw_5_cdec_5NTRef_1__init__, /*tp_init*/
+ 0, /*tp_alloc*/
+ __pyx_tp_new_5_cdec_NTRef, /*tp_new*/
+ 0, /*tp_free*/
+ 0, /*tp_is_gc*/
+ 0, /*tp_bases*/
+ 0, /*tp_mro*/
+ 0, /*tp_cache*/
+ 0, /*tp_subclasses*/
+ 0, /*tp_weaklist*/
+ 0, /*tp_del*/
+ #if PY_VERSION_HEX >= 0x02060000
+ 0, /*tp_version_tag*/
+ #endif
+};
+
+static PyObject *__pyx_tp_new_5_cdec_TRule(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ return o;
+}
+
+static void __pyx_tp_dealloc_5_cdec_TRule(PyObject *o) {
+ {
+ PyObject *etype, *eval, *etb;
+ PyErr_Fetch(&etype, &eval, &etb);
+ ++Py_REFCNT(o);
+ __pyx_pw_5_cdec_5TRule_3__dealloc__(o);
+ if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+ --Py_REFCNT(o);
+ PyErr_Restore(etype, eval, etb);
+ }
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_5TRule_arity(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_5TRule_5arity_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_5TRule_f(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_5TRule_1f_1__get__(o);
+}
+
+static int __pyx_setprop_5_cdec_5TRule_f(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+ if (v) {
+ return __pyx_pw_5_cdec_5TRule_1f_3__set__(o, v);
+ }
+ else {
+ PyErr_SetString(PyExc_NotImplementedError, "__del__");
+ return -1;
+ }
+}
+
+static PyObject *__pyx_getprop_5_cdec_5TRule_e(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_5TRule_1e_1__get__(o);
+}
+
+static int __pyx_setprop_5_cdec_5TRule_e(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+ if (v) {
+ return __pyx_pw_5_cdec_5TRule_1e_3__set__(o, v);
+ }
+ else {
+ PyErr_SetString(PyExc_NotImplementedError, "__del__");
+ return -1;
+ }
+}
+
+static PyObject *__pyx_getprop_5_cdec_5TRule_a(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_5TRule_1a_1__get__(o);
+}
+
+static int __pyx_setprop_5_cdec_5TRule_a(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+ if (v) {
+ return __pyx_pw_5_cdec_5TRule_1a_4__set__(o, v);
+ }
+ else {
+ PyErr_SetString(PyExc_NotImplementedError, "__del__");
+ return -1;
+ }
+}
+
+static PyObject *__pyx_getprop_5_cdec_5TRule_scores(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_5TRule_6scores_1__get__(o);
+}
+
+static int __pyx_setprop_5_cdec_5TRule_scores(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+ if (v) {
+ return __pyx_pw_5_cdec_5TRule_6scores_3__set__(o, v);
+ }
+ else {
+ PyErr_SetString(PyExc_NotImplementedError, "__del__");
+ return -1;
+ }
+}
+
+static PyObject *__pyx_getprop_5_cdec_5TRule_lhs(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_5TRule_3lhs_1__get__(o);
+}
+
+static int __pyx_setprop_5_cdec_5TRule_lhs(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+ if (v) {
+ return __pyx_pw_5_cdec_5TRule_3lhs_3__set__(o, v);
+ }
+ else {
+ PyErr_SetString(PyExc_NotImplementedError, "__del__");
+ return -1;
+ }
+}
+
+static PyMethodDef __pyx_methods_5_cdec_TRule[] = {
+ {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_5_cdec_TRule[] = {
+ {(char *)"arity", __pyx_getprop_5_cdec_5TRule_arity, 0, 0, 0},
+ {(char *)"f", __pyx_getprop_5_cdec_5TRule_f, __pyx_setprop_5_cdec_5TRule_f, 0, 0},
+ {(char *)"e", __pyx_getprop_5_cdec_5TRule_e, __pyx_setprop_5_cdec_5TRule_e, 0, 0},
+ {(char *)"a", __pyx_getprop_5_cdec_5TRule_a, __pyx_setprop_5_cdec_5TRule_a, 0, 0},
+ {(char *)"scores", __pyx_getprop_5_cdec_5TRule_scores, __pyx_setprop_5_cdec_5TRule_scores, 0, 0},
+ {(char *)"lhs", __pyx_getprop_5_cdec_5TRule_lhs, __pyx_setprop_5_cdec_5TRule_lhs, 0, 0},
+ {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_TRule = {
+ 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_TRule = {
+ 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_TRule = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_TRule = {
+ #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_TRule = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.TRule"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_TRule), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_TRule, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ #if PY_MAJOR_VERSION < 3
+ 0, /*tp_compare*/
+ #else
+ 0, /*reserved*/
+ #endif
+ 0, /*tp_repr*/
+ &__pyx_tp_as_number_TRule, /*tp_as_number*/
+ &__pyx_tp_as_sequence_TRule, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_TRule, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ __pyx_pw_5_cdec_5TRule_5__str__, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_TRule, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_TRule, /*tp_methods*/
+ 0, /*tp_members*/
+ __pyx_getsets_5_cdec_TRule, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ __pyx_pw_5_cdec_5TRule_1__init__, /*tp_init*/
+ 0, /*tp_alloc*/
+ __pyx_tp_new_5_cdec_TRule, /*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_MRule(PyTypeObject *t, PyObject *a, PyObject *k) {
+ PyObject *o = __pyx_tp_new_5_cdec_TRule(t, a, k);
+ if (!o) return 0;
+ return o;
+}
+
+static PyMethodDef __pyx_methods_5_cdec_MRule[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_MRule = {
+ 0, /*nb_add*/
+ 0, /*nb_subtract*/
+ 0, /*nb_multiply*/
+ #if PY_MAJOR_VERSION < 3
+ 0, /*nb_divide*/
+ #endif
+ 0, /*nb_remainder*/
+ 0, /*nb_divmod*/
+ 0, /*nb_power*/
+ 0, /*nb_negative*/
+ 0, /*nb_positive*/
+ 0, /*nb_absolute*/
+ 0, /*nb_nonzero*/
+ 0, /*nb_invert*/
+ 0, /*nb_lshift*/
+ 0, /*nb_rshift*/
+ 0, /*nb_and*/
+ 0, /*nb_xor*/
+ 0, /*nb_or*/
+ #if PY_MAJOR_VERSION < 3
+ 0, /*nb_coerce*/
+ #endif
+ 0, /*nb_int*/
+ #if PY_MAJOR_VERSION < 3
+ 0, /*nb_long*/
+ #else
+ 0, /*reserved*/
+ #endif
+ 0, /*nb_float*/
+ #if PY_MAJOR_VERSION < 3
+ 0, /*nb_oct*/
+ #endif
+ #if PY_MAJOR_VERSION < 3
+ 0, /*nb_hex*/
+ #endif
+ 0, /*nb_inplace_add*/
+ 0, /*nb_inplace_subtract*/
+ 0, /*nb_inplace_multiply*/
+ #if PY_MAJOR_VERSION < 3
+ 0, /*nb_inplace_divide*/
+ #endif
+ 0, /*nb_inplace_remainder*/
+ 0, /*nb_inplace_power*/
+ 0, /*nb_inplace_lshift*/
+ 0, /*nb_inplace_rshift*/
+ 0, /*nb_inplace_and*/
+ 0, /*nb_inplace_xor*/
+ 0, /*nb_inplace_or*/
+ 0, /*nb_floor_divide*/
+ 0, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ 0, /*nb_inplace_true_divide*/
+ #if PY_VERSION_HEX >= 0x02050000
+ 0, /*nb_index*/
+ #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_MRule = {
+ 0, /*sq_length*/
+ 0, /*sq_concat*/
+ 0, /*sq_repeat*/
+ 0, /*sq_item*/
+ 0, /*sq_slice*/
+ 0, /*sq_ass_item*/
+ 0, /*sq_ass_slice*/
+ 0, /*sq_contains*/
+ 0, /*sq_inplace_concat*/
+ 0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_MRule = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_MRule = {
+ #if PY_MAJOR_VERSION < 3
+ 0, /*bf_getreadbuffer*/
+ #endif
+ #if PY_MAJOR_VERSION < 3
+ 0, /*bf_getwritebuffer*/
+ #endif
+ #if PY_MAJOR_VERSION < 3
+ 0, /*bf_getsegcount*/
+ #endif
+ #if PY_MAJOR_VERSION < 3
+ 0, /*bf_getcharbuffer*/
+ #endif
+ #if PY_VERSION_HEX >= 0x02060000
+ 0, /*bf_getbuffer*/
+ #endif
+ #if PY_VERSION_HEX >= 0x02060000
+ 0, /*bf_releasebuffer*/
+ #endif
+};
+
+static PyTypeObject __pyx_type_5_cdec_MRule = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.MRule"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_MRule), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_TRule, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ #if PY_MAJOR_VERSION < 3
+ 0, /*tp_compare*/
+ #else
+ 0, /*reserved*/
+ #endif
+ 0, /*tp_repr*/
+ &__pyx_tp_as_number_MRule, /*tp_as_number*/
+ &__pyx_tp_as_sequence_MRule, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_MRule, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ #if CYTHON_COMPILING_IN_PYPY
+ __pyx_pw_5_cdec_5TRule_5__str__, /*tp_str*/
+ #else
+ 0, /*tp_str*/
+ #endif
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_MRule, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_MRule, /*tp_methods*/
+ 0, /*tp_members*/
+ 0, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ __pyx_pw_5_cdec_5MRule_1__init__, /*tp_init*/
+ 0, /*tp_alloc*/
+ __pyx_tp_new_5_cdec_MRule, /*tp_new*/
+ 0, /*tp_free*/
+ 0, /*tp_is_gc*/
+ 0, /*tp_bases*/
+ 0, /*tp_mro*/
+ 0, /*tp_cache*/
+ 0, /*tp_subclasses*/
+ 0, /*tp_weaklist*/
+ 0, /*tp_del*/
+ #if PY_VERSION_HEX >= 0x02060000
+ 0, /*tp_version_tag*/
+ #endif
+};
+
+static PyObject *__pyx_tp_new_5_cdec_Grammar(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ return o;
+}
+
+static void __pyx_tp_dealloc_5_cdec_Grammar(PyObject *o) {
+ {
+ PyObject *etype, *eval, *etb;
+ PyErr_Fetch(&etype, &eval, &etb);
+ ++Py_REFCNT(o);
+ __pyx_pw_5_cdec_7Grammar_1__dealloc__(o);
+ if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+ --Py_REFCNT(o);
+ PyErr_Restore(etype, eval, etb);
+ }
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_7Grammar_name(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_7Grammar_4name_1__get__(o);
+}
+
+static int __pyx_setprop_5_cdec_7Grammar_name(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+ if (v) {
+ return __pyx_pw_5_cdec_7Grammar_4name_3__set__(o, v);
+ }
+ else {
+ PyErr_SetString(PyExc_NotImplementedError, "__del__");
+ return -1;
+ }
+}
+
+static PyMethodDef __pyx_methods_5_cdec_Grammar[] = {
+ {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_5_cdec_Grammar[] = {
+ {(char *)"name", __pyx_getprop_5_cdec_7Grammar_name, __pyx_setprop_5_cdec_7Grammar_name, 0, 0},
+ {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_Grammar = {
+ 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_Grammar = {
+ 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_Grammar = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_Grammar = {
+ #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_Grammar = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.Grammar"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_Grammar), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_Grammar, /*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_Grammar, /*tp_as_number*/
+ &__pyx_tp_as_sequence_Grammar, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_Grammar, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_Grammar, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ __pyx_pw_5_cdec_7Grammar_3__iter__, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_Grammar, /*tp_methods*/
+ 0, /*tp_members*/
+ __pyx_getsets_5_cdec_Grammar, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
0, /*tp_descr_get*/
@@ -3641,7 +20086,178 @@ static PyTypeObject __pyx_type_5_cdec_Decoder = {
0, /*tp_dictoffset*/
0, /*tp_init*/
0, /*tp_alloc*/
- __pyx_tp_new_5_cdec_Decoder, /*tp_new*/
+ __pyx_tp_new_5_cdec_Grammar, /*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_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;
+}
+
+static PyMethodDef __pyx_methods_5_cdec_TextGrammar[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_TextGrammar = {
+ 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_TextGrammar = {
+ 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_TextGrammar = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_TextGrammar = {
+ #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_TextGrammar = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.TextGrammar"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_TextGrammar), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_Grammar, /*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_TextGrammar, /*tp_as_number*/
+ &__pyx_tp_as_sequence_TextGrammar, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_TextGrammar, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_TextGrammar, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ #if CYTHON_COMPILING_IN_PYPY
+ __pyx_pw_5_cdec_7Grammar_3__iter__, /*tp_iter*/
+ #else
+ 0, /*tp_iter*/
+ #endif
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_TextGrammar, /*tp_methods*/
+ 0, /*tp_members*/
+ 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_TextGrammar, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
@@ -3655,7 +20271,7 @@ static PyTypeObject __pyx_type_5_cdec_Decoder = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec_Hypergraph(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec_Hypergraph(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
return o;
@@ -3674,16 +20290,47 @@ static void __pyx_tp_dealloc_5_cdec_Hypergraph(PyObject *o) {
(*Py_TYPE(o)->tp_free)(o);
}
+static PyObject *__pyx_getprop_5_cdec_10Hypergraph_edges(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_10Hypergraph_5edges_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_10Hypergraph_nodes(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_10Hypergraph_5nodes_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_10Hypergraph_goal(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_10Hypergraph_4goal_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_10Hypergraph_npaths(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_10Hypergraph_6npaths_1__get__(o);
+}
+
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_tree"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_5viterbi_tree, METH_NOARGS, __Pyx_DOCSTR(0)},
- {__Pyx_NAMESTR("kbest"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_7kbest, METH_O, __Pyx_DOCSTR(0)},
- {__Pyx_NAMESTR("kbest_tree"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_10kbest_tree, METH_O, __Pyx_DOCSTR(0)},
- {__Pyx_NAMESTR("intersect"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_13intersect, METH_O, __Pyx_DOCSTR(0)},
- {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_15sample, METH_O, __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)},
{0, 0, 0, 0}
};
+static struct PyGetSetDef __pyx_getsets_5_cdec_Hypergraph[] = {
+ {(char *)"edges", __pyx_getprop_5_cdec_10Hypergraph_edges, 0, 0, 0},
+ {(char *)"nodes", __pyx_getprop_5_cdec_10Hypergraph_nodes, 0, 0, 0},
+ {(char *)"goal", __pyx_getprop_5_cdec_10Hypergraph_goal, 0, 0, 0},
+ {(char *)"npaths", __pyx_getprop_5_cdec_10Hypergraph_npaths, 0, 0, 0},
+ {0, 0, 0, 0, 0}
+};
+
static PyNumberMethods __pyx_tp_as_number_Hypergraph = {
0, /*nb_add*/
0, /*nb_subtract*/
@@ -3816,7 +20463,7 @@ static PyTypeObject __pyx_type_5_cdec_Hypergraph = {
0, /*tp_iternext*/
__pyx_methods_5_cdec_Hypergraph, /*tp_methods*/
0, /*tp_members*/
- 0, /*tp_getset*/
+ __pyx_getsets_5_cdec_Hypergraph, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
0, /*tp_descr_get*/
@@ -3837,10 +20484,445 @@ static PyTypeObject __pyx_type_5_cdec_Hypergraph = {
0, /*tp_version_tag*/
#endif
};
+static struct __pyx_vtabstruct_5_cdec_HypergraphEdge __pyx_vtable_5_cdec_HypergraphEdge;
+
+static PyObject *__pyx_tp_new_5_cdec_HypergraphEdge(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec_HypergraphEdge *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec_HypergraphEdge *)o);
+ p->__pyx_vtab = __pyx_vtabptr_5_cdec_HypergraphEdge;
+ p->trule = ((struct __pyx_obj_5_cdec_TRule *)Py_None); Py_INCREF(Py_None);
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec_HypergraphEdge(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec_HypergraphEdge *p = (struct __pyx_obj_5_cdec_HypergraphEdge *)o;
+ if (p->trule) {
+ e = (*v)(((PyObject*)p->trule), a); if (e) return e;
+ }
+ return 0;
+}
+
+static int __pyx_tp_clear_5_cdec_HypergraphEdge(PyObject *o) {
+ struct __pyx_obj_5_cdec_HypergraphEdge *p = (struct __pyx_obj_5_cdec_HypergraphEdge *)o;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->trule);
+ p->trule = ((struct __pyx_obj_5_cdec_TRule *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_head_node(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_14HypergraphEdge_9head_node_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_tail_nodes(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_14HypergraphEdge_10tail_nodes_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_span(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_14HypergraphEdge_4span_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_feature_values(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_14HypergraphEdge_14feature_values_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_prob(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_14HypergraphEdge_4prob_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_14HypergraphEdge_trule(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_14HypergraphEdge_5trule_1__get__(o);
+}
+
+static int __pyx_setprop_5_cdec_14HypergraphEdge_trule(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+ if (v) {
+ return __pyx_pw_5_cdec_14HypergraphEdge_5trule_3__set__(o, v);
+ }
+ else {
+ return __pyx_pw_5_cdec_14HypergraphEdge_5trule_5__del__(o);
+ }
+}
+
+static PyMethodDef __pyx_methods_5_cdec_HypergraphEdge[] = {
+ {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_5_cdec_HypergraphEdge[] = {
+ {(char *)"head_node", __pyx_getprop_5_cdec_14HypergraphEdge_head_node, 0, 0, 0},
+ {(char *)"tail_nodes", __pyx_getprop_5_cdec_14HypergraphEdge_tail_nodes, 0, 0, 0},
+ {(char *)"span", __pyx_getprop_5_cdec_14HypergraphEdge_span, 0, 0, 0},
+ {(char *)"feature_values", __pyx_getprop_5_cdec_14HypergraphEdge_feature_values, 0, 0, 0},
+ {(char *)"prob", __pyx_getprop_5_cdec_14HypergraphEdge_prob, 0, 0, 0},
+ {(char *)"trule", __pyx_getprop_5_cdec_14HypergraphEdge_trule, __pyx_setprop_5_cdec_14HypergraphEdge_trule, 0, 0},
+ {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_HypergraphEdge = {
+ 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_HypergraphEdge = {
+ __pyx_pw_5_cdec_14HypergraphEdge_1__len__, /*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_HypergraphEdge = {
+ __pyx_pw_5_cdec_14HypergraphEdge_1__len__, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_HypergraphEdge = {
+ #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_HypergraphEdge = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.HypergraphEdge"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_HypergraphEdge), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_HypergraphEdge, /*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_HypergraphEdge, /*tp_as_number*/
+ &__pyx_tp_as_sequence_HypergraphEdge, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_HypergraphEdge, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_HypergraphEdge, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+ 0, /*tp_doc*/
+ __pyx_tp_traverse_5_cdec_HypergraphEdge, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec_HypergraphEdge, /*tp_clear*/
+ __pyx_pw_5_cdec_14HypergraphEdge_3__richcmp__, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_HypergraphEdge, /*tp_methods*/
+ 0, /*tp_members*/
+ __pyx_getsets_5_cdec_HypergraphEdge, /*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_HypergraphEdge, /*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 struct __pyx_vtabstruct_5_cdec_HypergraphNode __pyx_vtable_5_cdec_HypergraphNode;
+
+static PyObject *__pyx_tp_new_5_cdec_HypergraphNode(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec_HypergraphNode *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec_HypergraphNode *)o);
+ p->__pyx_vtab = __pyx_vtabptr_5_cdec_HypergraphNode;
+ return o;
+}
+
+static void __pyx_tp_dealloc_5_cdec_HypergraphNode(PyObject *o) {
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_14HypergraphNode_in_edges(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_14HypergraphNode_8in_edges_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_14HypergraphNode_out_edges(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_14HypergraphNode_9out_edges_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_14HypergraphNode_span(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_14HypergraphNode_4span_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_14HypergraphNode_cat(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_14HypergraphNode_3cat_1__get__(o);
+}
+
+static PyMethodDef __pyx_methods_5_cdec_HypergraphNode[] = {
+ {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_5_cdec_HypergraphNode[] = {
+ {(char *)"in_edges", __pyx_getprop_5_cdec_14HypergraphNode_in_edges, 0, 0, 0},
+ {(char *)"out_edges", __pyx_getprop_5_cdec_14HypergraphNode_out_edges, 0, 0, 0},
+ {(char *)"span", __pyx_getprop_5_cdec_14HypergraphNode_span, 0, 0, 0},
+ {(char *)"cat", __pyx_getprop_5_cdec_14HypergraphNode_cat, 0, 0, 0},
+ {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_HypergraphNode = {
+ 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_HypergraphNode = {
+ 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_HypergraphNode = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_HypergraphNode = {
+ #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_HypergraphNode = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.HypergraphNode"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_HypergraphNode), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_HypergraphNode, /*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_HypergraphNode, /*tp_as_number*/
+ &__pyx_tp_as_sequence_HypergraphNode, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_HypergraphNode, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_HypergraphNode, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ __pyx_pw_5_cdec_14HypergraphNode_1__richcmp__, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_HypergraphNode, /*tp_methods*/
+ 0, /*tp_members*/
+ __pyx_getsets_5_cdec_HypergraphNode, /*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_HypergraphNode, /*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_Lattice(PyTypeObject *t, PyObject *a, 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) {
+ Py_DECREF(o); o = 0;
+ }
return o;
}
@@ -3849,15 +20931,34 @@ 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_7__dealloc__(o);
+ __pyx_pw_5_cdec_7Lattice_3__dealloc__(o);
if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
--Py_REFCNT(o);
PyErr_Restore(etype, eval, etb);
}
(*Py_TYPE(o)->tp_free)(o);
}
+static PyObject *__pyx_sq_item_5_cdec_Lattice(PyObject *o, Py_ssize_t i) {
+ PyObject *r;
+ PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
+ r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
+ Py_DECREF(x);
+ return r;
+}
+
+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);
+ }
+ else {
+ PyErr_Format(PyExc_NotImplementedError,
+ "Subscript deletion not supported by %s", Py_TYPE(o)->tp_name);
+ return -1;
+ }
+}
static PyMethodDef __pyx_methods_5_cdec_Lattice[] = {
+ {__Pyx_NAMESTR("todot"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_16todot, METH_NOARGS, __Pyx_DOCSTR(0)},
{0, 0, 0, 0}
};
@@ -3920,10 +21021,10 @@ static PyNumberMethods __pyx_tp_as_number_Lattice = {
};
static PySequenceMethods __pyx_tp_as_sequence_Lattice = {
- 0, /*sq_length*/
+ __pyx_pw_5_cdec_7Lattice_9__len__, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
- 0, /*sq_item*/
+ __pyx_sq_item_5_cdec_Lattice, /*sq_item*/
0, /*sq_slice*/
0, /*sq_ass_item*/
0, /*sq_ass_slice*/
@@ -3933,9 +21034,9 @@ static PySequenceMethods __pyx_tp_as_sequence_Lattice = {
};
static PyMappingMethods __pyx_tp_as_mapping_Lattice = {
- 0, /*mp_length*/
- 0, /*mp_subscript*/
- 0, /*mp_ass_subscript*/
+ __pyx_pw_5_cdec_7Lattice_9__len__, /*mp_length*/
+ __pyx_pw_5_cdec_7Lattice_5__getitem__, /*mp_subscript*/
+ __pyx_mp_ass_subscript_5_cdec_Lattice, /*mp_ass_subscript*/
};
static PyBufferProcs __pyx_tp_as_buffer_Lattice = {
@@ -3979,7 +21080,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_3__str__, /*tp_str*/
+ __pyx_pw_5_cdec_7Lattice_11__str__, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
&__pyx_tp_as_buffer_Lattice, /*tp_as_buffer*/
@@ -3989,7 +21090,7 @@ static PyTypeObject __pyx_type_5_cdec_Lattice = {
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
- __pyx_pw_5_cdec_7Lattice_5__iter__, /*tp_iter*/
+ __pyx_pw_5_cdec_7Lattice_13__iter__, /*tp_iter*/
0, /*tp_iternext*/
__pyx_methods_5_cdec_Lattice, /*tp_methods*/
0, /*tp_members*/
@@ -3999,7 +21100,7 @@ static PyTypeObject __pyx_type_5_cdec_Lattice = {
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
- __pyx_pw_5_cdec_7Lattice_1__init__, /*tp_init*/
+ 0, /*tp_init*/
0, /*tp_alloc*/
__pyx_tp_new_5_cdec_Lattice, /*tp_new*/
0, /*tp_free*/
@@ -4015,7 +21116,1374 @@ static PyTypeObject __pyx_type_5_cdec_Lattice = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct____iter__(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_5_cdec_Candidate(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ return o;
+}
+
+static void __pyx_tp_dealloc_5_cdec_Candidate(PyObject *o) {
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_9Candidate_words(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_9Candidate_5words_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_9Candidate_fmap(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_9Candidate_4fmap_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_9Candidate_score(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_9Candidate_5score_1__get__(o);
+}
+
+static int __pyx_setprop_5_cdec_9Candidate_score(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+ if (v) {
+ return __pyx_pw_5_cdec_9Candidate_5score_3__set__(o, v);
+ }
+ else {
+ PyErr_SetString(PyExc_NotImplementedError, "__del__");
+ return -1;
+ }
+}
+
+static PyMethodDef __pyx_methods_5_cdec_Candidate[] = {
+ {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_5_cdec_Candidate[] = {
+ {(char *)"words", __pyx_getprop_5_cdec_9Candidate_words, 0, 0, 0},
+ {(char *)"fmap", __pyx_getprop_5_cdec_9Candidate_fmap, 0, 0, 0},
+ {(char *)"score", __pyx_getprop_5_cdec_9Candidate_score, __pyx_setprop_5_cdec_9Candidate_score, 0, 0},
+ {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_Candidate = {
+ 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_Candidate = {
+ 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_Candidate = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_Candidate = {
+ #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_Candidate = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.Candidate"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_Candidate), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_Candidate, /*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_Candidate, /*tp_as_number*/
+ &__pyx_tp_as_sequence_Candidate, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_Candidate, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_Candidate, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_Candidate, /*tp_methods*/
+ 0, /*tp_members*/
+ __pyx_getsets_5_cdec_Candidate, /*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_Candidate, /*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_SufficientStats(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ return o;
+}
+
+static void __pyx_tp_dealloc_5_cdec_SufficientStats(PyObject *o) {
+ {
+ PyObject *etype, *eval, *etb;
+ PyErr_Fetch(&etype, &eval, &etb);
+ ++Py_REFCNT(o);
+ __pyx_pw_5_cdec_15SufficientStats_1__dealloc__(o);
+ if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+ --Py_REFCNT(o);
+ PyErr_Restore(etype, eval, etb);
+ }
+ (*Py_TYPE(o)->tp_free)(o);
+}
+static PyObject *__pyx_sq_item_5_cdec_SufficientStats(PyObject *o, Py_ssize_t i) {
+ PyObject *r;
+ PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
+ r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
+ Py_DECREF(x);
+ return r;
+}
+
+static PyObject *__pyx_getprop_5_cdec_15SufficientStats_score(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_15SufficientStats_5score_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5_cdec_15SufficientStats_detail(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_15SufficientStats_6detail_1__get__(o);
+}
+
+static PyMethodDef __pyx_methods_5_cdec_SufficientStats[] = {
+ {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_5_cdec_SufficientStats[] = {
+ {(char *)"score", __pyx_getprop_5_cdec_15SufficientStats_score, 0, 0, 0},
+ {(char *)"detail", __pyx_getprop_5_cdec_15SufficientStats_detail, 0, 0, 0},
+ {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_SufficientStats = {
+ __pyx_pw_5_cdec_15SufficientStats_12__add__, /*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
+ __pyx_pw_5_cdec_15SufficientStats_10__iadd__, /*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_SufficientStats = {
+ __pyx_pw_5_cdec_15SufficientStats_3__len__, /*sq_length*/
+ 0, /*sq_concat*/
+ 0, /*sq_repeat*/
+ __pyx_sq_item_5_cdec_SufficientStats, /*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_SufficientStats = {
+ __pyx_pw_5_cdec_15SufficientStats_3__len__, /*mp_length*/
+ __pyx_pw_5_cdec_15SufficientStats_8__getitem__, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_SufficientStats = {
+ #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_SufficientStats = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.SufficientStats"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_SufficientStats), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_SufficientStats, /*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_SufficientStats, /*tp_as_number*/
+ &__pyx_tp_as_sequence_SufficientStats, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_SufficientStats, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_SufficientStats, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ __pyx_pw_5_cdec_15SufficientStats_5__iter__, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_SufficientStats, /*tp_methods*/
+ 0, /*tp_members*/
+ __pyx_getsets_5_cdec_SufficientStats, /*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_SufficientStats, /*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_CandidateSet(PyTypeObject *t, PyObject *a, PyObject *k) {
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ if (__pyx_pw_5_cdec_12CandidateSet_1__cinit__(o, a, k) < 0) {
+ Py_DECREF(o); o = 0;
+ }
+ return o;
+}
+
+static void __pyx_tp_dealloc_5_cdec_CandidateSet(PyObject *o) {
+ {
+ PyObject *etype, *eval, *etb;
+ PyErr_Fetch(&etype, &eval, &etb);
+ ++Py_REFCNT(o);
+ __pyx_pw_5_cdec_12CandidateSet_3__dealloc__(o);
+ if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+ --Py_REFCNT(o);
+ PyErr_Restore(etype, eval, etb);
+ }
+ (*Py_TYPE(o)->tp_free)(o);
+}
+static PyObject *__pyx_sq_item_5_cdec_CandidateSet(PyObject *o, Py_ssize_t i) {
+ PyObject *r;
+ PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
+ r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
+ Py_DECREF(x);
+ return r;
+}
+
+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)},
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_CandidateSet = {
+ 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_CandidateSet = {
+ __pyx_pw_5_cdec_12CandidateSet_5__len__, /*sq_length*/
+ 0, /*sq_concat*/
+ 0, /*sq_repeat*/
+ __pyx_sq_item_5_cdec_CandidateSet, /*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_CandidateSet = {
+ __pyx_pw_5_cdec_12CandidateSet_5__len__, /*mp_length*/
+ __pyx_pw_5_cdec_12CandidateSet_7__getitem__, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_CandidateSet = {
+ #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_CandidateSet = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.CandidateSet"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_CandidateSet), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_CandidateSet, /*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_CandidateSet, /*tp_as_number*/
+ &__pyx_tp_as_sequence_CandidateSet, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_CandidateSet, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_CandidateSet, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ __pyx_pw_5_cdec_12CandidateSet_9__iter__, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_CandidateSet, /*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_CandidateSet, /*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_SegmentEvaluator(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ return o;
+}
+
+static void __pyx_tp_dealloc_5_cdec_SegmentEvaluator(PyObject *o) {
+ {
+ PyObject *etype, *eval, *etb;
+ PyErr_Fetch(&etype, &eval, &etb);
+ ++Py_REFCNT(o);
+ __pyx_pw_5_cdec_16SegmentEvaluator_1__dealloc__(o);
+ if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+ --Py_REFCNT(o);
+ PyErr_Restore(etype, eval, etb);
+ }
+ (*Py_TYPE(o)->tp_free)(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)},
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_SegmentEvaluator = {
+ 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_SegmentEvaluator = {
+ 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_SegmentEvaluator = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_SegmentEvaluator = {
+ #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_SegmentEvaluator = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.SegmentEvaluator"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_SegmentEvaluator), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_SegmentEvaluator, /*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_SegmentEvaluator, /*tp_as_number*/
+ &__pyx_tp_as_sequence_SegmentEvaluator, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_SegmentEvaluator, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_SegmentEvaluator, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_SegmentEvaluator, /*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_SegmentEvaluator, /*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_Scorer(PyTypeObject *t, PyObject *a, PyObject *k) {
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ if (__pyx_pw_5_cdec_6Scorer_1__cinit__(o, a, k) < 0) {
+ Py_DECREF(o); o = 0;
+ }
+ return o;
+}
+
+static void __pyx_tp_dealloc_5_cdec_Scorer(PyObject *o) {
+ {
+ PyObject *etype, *eval, *etb;
+ PyErr_Fetch(&etype, &eval, &etb);
+ ++Py_REFCNT(o);
+ __pyx_pw_5_cdec_6Scorer_3__dealloc__(o);
+ if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+ --Py_REFCNT(o);
+ PyErr_Restore(etype, eval, etb);
+ }
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyMethodDef __pyx_methods_5_cdec_Scorer[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_Scorer = {
+ 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_Scorer = {
+ 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_Scorer = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_Scorer = {
+ #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_Scorer = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.Scorer"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_Scorer), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_Scorer, /*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_Scorer, /*tp_as_number*/
+ &__pyx_tp_as_sequence_Scorer, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_Scorer, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ __pyx_pw_5_cdec_6Scorer_5__call__, /*tp_call*/
+ __pyx_pw_5_cdec_6Scorer_7__str__, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_Scorer, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_Scorer, /*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_Scorer, /*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_Metric(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec_Metric *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec_Metric *)o);
+ p->scorer = ((struct __pyx_obj_5_cdec_Scorer *)Py_None); Py_INCREF(Py_None);
+ if (__pyx_pw_5_cdec_6Metric_1__cinit__(o, __pyx_empty_tuple, NULL) < 0) {
+ Py_DECREF(o); o = 0;
+ }
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec_Metric(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec_Metric *p = (struct __pyx_obj_5_cdec_Metric *)o;
+ if (p->scorer) {
+ e = (*v)(((PyObject*)p->scorer), a); if (e) return e;
+ }
+ return 0;
+}
+
+static int __pyx_tp_clear_5_cdec_Metric(PyObject *o) {
+ struct __pyx_obj_5_cdec_Metric *p = (struct __pyx_obj_5_cdec_Metric *)o;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->scorer);
+ p->scorer = ((struct __pyx_obj_5_cdec_Scorer *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec_Metric[] = {
+ {__Pyx_NAMESTR("score"), (PyCFunction)__pyx_pw_5_cdec_6Metric_5score, METH_NOARGS, __Pyx_DOCSTR(0)},
+ {__Pyx_NAMESTR("evaluate"), (PyCFunction)__pyx_pw_5_cdec_6Metric_7evaluate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_Metric = {
+ 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_Metric = {
+ 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_Metric = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_Metric = {
+ #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_Metric = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.Metric"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_Metric), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_Metric, /*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_Metric, /*tp_as_number*/
+ &__pyx_tp_as_sequence_Metric, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_Metric, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ __pyx_pw_5_cdec_6Metric_3__call__, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_Metric, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+ 0, /*tp_doc*/
+ __pyx_tp_traverse_5_cdec_Metric, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec_Metric, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_Metric, /*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_Metric, /*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_Decoder(PyTypeObject *t, PyObject *a, 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;
+}
+
+static void __pyx_tp_dealloc_5_cdec_Decoder(PyObject *o) {
+ struct __pyx_obj_5_cdec_Decoder *p = (struct __pyx_obj_5_cdec_Decoder *)o;
+ {
+ PyObject *etype, *eval, *etb;
+ PyErr_Fetch(&etype, &eval, &etb);
+ ++Py_REFCNT(o);
+ __pyx_pw_5_cdec_7Decoder_3__dealloc__(o);
+ if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+ --Py_REFCNT(o);
+ PyErr_Restore(etype, eval, etb);
+ }
+ Py_XDECREF(((PyObject *)p->weights));
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec_Decoder(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec_Decoder *p = (struct __pyx_obj_5_cdec_Decoder *)o;
+ if (p->weights) {
+ e = (*v)(((PyObject*)p->weights), a); if (e) return e;
+ }
+ return 0;
+}
+
+static int __pyx_tp_clear_5_cdec_Decoder(PyObject *o) {
+ struct __pyx_obj_5_cdec_Decoder *p = (struct __pyx_obj_5_cdec_Decoder *)o;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->weights);
+ p->weights = ((struct __pyx_obj_5_cdec_DenseVector *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyObject *__pyx_getprop_5_cdec_7Decoder_weights(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_7Decoder_7weights_1__get__(o);
+}
+
+static int __pyx_setprop_5_cdec_7Decoder_weights(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+ if (v) {
+ return __pyx_pw_5_cdec_7Decoder_7weights_3__set__(o, v);
+ }
+ else {
+ PyErr_SetString(PyExc_NotImplementedError, "__del__");
+ return -1;
+ }
+}
+
+static PyObject *__pyx_getprop_5_cdec_7Decoder_formalism(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5_cdec_7Decoder_9formalism_1__get__(o);
+}
+
+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)},
+ {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_5_cdec_Decoder[] = {
+ {(char *)"weights", __pyx_getprop_5_cdec_7Decoder_weights, __pyx_setprop_5_cdec_7Decoder_weights, 0, 0},
+ {(char *)"formalism", __pyx_getprop_5_cdec_7Decoder_formalism, 0, 0, 0},
+ {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_Decoder = {
+ 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_Decoder = {
+ 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_Decoder = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_Decoder = {
+ #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_Decoder = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.Decoder"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec_Decoder), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec_Decoder, /*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_Decoder, /*tp_as_number*/
+ &__pyx_tp_as_sequence_Decoder, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping_Decoder, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ &__pyx_tp_as_buffer_Decoder, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+ 0, /*tp_doc*/
+ __pyx_tp_traverse_5_cdec_Decoder, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec_Decoder, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec_Decoder, /*tp_methods*/
+ 0, /*tp_members*/
+ __pyx_getsets_5_cdec_Decoder, /*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_Decoder, /*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____iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -4043,7 +22511,7 @@ static int __pyx_tp_clear_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;
PyObject* tmp;
tmp = ((PyObject*)p->__pyx_v_self);
- p->__pyx_v_self = ((struct __pyx_obj_5_cdec_Weights *)Py_None); Py_INCREF(Py_None);
+ p->__pyx_v_self = ((struct __pyx_obj_5_cdec_DenseVector *)Py_None); Py_INCREF(Py_None);
Py_XDECREF(tmp);
return 0;
}
@@ -4206,42 +22674,1414 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct____iter__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_1_kbest(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest *p;
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_1___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ *)o);
+ p->__pyx_v_self = 0;
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_1___iter__(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_1___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_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;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_self);
+ p->__pyx_v_self = ((struct __pyx_obj_5_cdec_SparseVector *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_1___iter__[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_1___iter__ = {
+ 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_1___iter__ = {
+ 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_1___iter__ = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_1___iter__ = {
+ #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_1___iter__ = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_1___iter__"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_1___iter__, /*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_1___iter__, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_1___iter__, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_1___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_1___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_1___iter__, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_1___iter__, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_1___iter__, /*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_1___iter__, /*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_2__phrase(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *)o);
+ p->__pyx_v_phrase = 0;
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_2__phrase(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *)o;
+ if (p->__pyx_v_phrase) {
+ e = (*v)(p->__pyx_v_phrase, a); if (e) return e;
+ }
+ return 0;
+}
+
+static int __pyx_tp_clear_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;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_phrase);
+ p->__pyx_v_phrase = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_2__phrase[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_2__phrase = {
+ 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_2__phrase = {
+ 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_2__phrase = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_2__phrase = {
+ #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_2__phrase = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_2__phrase"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_2__phrase, /*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_2__phrase, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_2__phrase, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_2__phrase, /*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_2__phrase, /*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_2__phrase, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_2__phrase, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_2__phrase, /*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_2__phrase, /*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_3_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr *)o);
+ p->__pyx_outer_scope = 0;
+ p->__pyx_v_w = 0;
+ p->__pyx_t_0 = 0;
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_3_genexpr(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr *)o;
+ if (p->__pyx_outer_scope) {
+ e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
+ }
+ if (p->__pyx_v_w) {
+ e = (*v)(p->__pyx_v_w, a); if (e) return e;
+ }
+ if (p->__pyx_t_0) {
+ e = (*v)(p->__pyx_t_0, a); if (e) return e;
+ }
+ return 0;
+}
+
+static int __pyx_tp_clear_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;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_outer_scope);
+ p->__pyx_outer_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_w);
+ p->__pyx_v_w = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_t_0);
+ p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_3_genexpr[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_3_genexpr = {
+ 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_3_genexpr = {
+ 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_3_genexpr = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_3_genexpr = {
+ #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_3_genexpr = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_3_genexpr"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_3_genexpr, /*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_3_genexpr, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_3_genexpr, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_3_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_3_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_3_genexpr, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_3_genexpr, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_3_genexpr, /*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_3_genexpr, /*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_4___get__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
- p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest *)o);
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *)o);
+ p->__pyx_v_self = 0;
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_4___get__(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_4___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_4___get__(PyObject *o) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *)o;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_self);
+ p->__pyx_v_self = ((struct __pyx_obj_5_cdec_TRule *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_4___get__[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_4___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_4___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_4___get__ = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_4___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_4___get__ = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_4___get__"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_4___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_4___get__, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_4___get__, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_4___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_4___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_4___get__, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_4___get__, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_4___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_4___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_5___str__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *)o);
+ p->__pyx_v_self = 0;
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_5___str__(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *)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_5___str__(PyObject *o) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *)o;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_self);
+ p->__pyx_v_self = ((struct __pyx_obj_5_cdec_TRule *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_5___str__[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_5___str__ = {
+ 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_5___str__ = {
+ 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_5___str__ = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_5___str__ = {
+ #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_5___str__ = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_5___str__"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_5___str__, /*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_5___str__, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_5___str__, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_5___str__, /*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_5___str__, /*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_5___str__, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_5___str__, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_5___str__, /*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_5___str__, /*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_6_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *)o);
+ p->__pyx_outer_scope = 0;
+ p->__pyx_v_feat = 0;
+ p->__pyx_t_0 = 0;
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_6_genexpr(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *)o;
+ if (p->__pyx_outer_scope) {
+ e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
+ }
+ if (p->__pyx_v_feat) {
+ e = (*v)(p->__pyx_v_feat, a); if (e) return e;
+ }
+ if (p->__pyx_t_0) {
+ e = (*v)(p->__pyx_t_0, a); if (e) return e;
+ }
+ return 0;
+}
+
+static int __pyx_tp_clear_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;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_outer_scope);
+ p->__pyx_outer_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_feat);
+ p->__pyx_v_feat = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_t_0);
+ p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_6_genexpr[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_6_genexpr = {
+ 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_6_genexpr = {
+ 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_6_genexpr = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_6_genexpr = {
+ #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_6_genexpr = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_6_genexpr"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_6_genexpr, /*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_6_genexpr, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_6_genexpr, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_6_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_6_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_6_genexpr, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_6_genexpr, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_6_genexpr, /*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_6_genexpr, /*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_7___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ *)o);
+ p->__pyx_v_self = 0;
+ p->__pyx_v_trule = 0;
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_7___iter__(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ *)o;
+ if (p->__pyx_v_self) {
+ e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
+ }
+ if (p->__pyx_v_trule) {
+ e = (*v)(((PyObject*)p->__pyx_v_trule), a); if (e) return e;
+ }
+ return 0;
+}
+
+static int __pyx_tp_clear_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;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_self);
+ p->__pyx_v_self = ((struct __pyx_obj_5_cdec_Grammar *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_trule);
+ p->__pyx_v_trule = ((struct __pyx_obj_5_cdec_TRule *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_7___iter__[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_7___iter__ = {
+ 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_7___iter__ = {
+ 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_7___iter__ = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_7___iter__ = {
+ #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_7___iter__ = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_7___iter__"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_7___iter__, /*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_7___iter__, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_7___iter__, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_7___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_7___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_7___iter__, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_7___iter__, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_7___iter__, /*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_7___iter__, /*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_8_kbest(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest *)o);
p->__pyx_v_self = 0;
p->__pyx_v_size = 0;
- p->__pyx_v_tree = 0;
return o;
}
-static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_1_kbest(PyObject *o) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest *)o;
+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_XDECREF(((PyObject *)p->__pyx_v_tree));
(*Py_TYPE(o)->tp_free)(o);
}
-static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_1_kbest(PyObject *o, visitproc v, void *a) {
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_8_kbest(PyObject *o, visitproc v, void *a) {
int e;
- struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest *)o;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest *)o;
if (p->__pyx_v_self) {
e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
}
if (p->__pyx_v_size) {
e = (*v)(p->__pyx_v_size, a); if (e) return e;
}
- if (p->__pyx_v_tree) {
- e = (*v)(p->__pyx_v_tree, a); if (e) return e;
- }
return 0;
}
-static int __pyx_tp_clear_5_cdec___pyx_scope_struct_1_kbest(PyObject *o) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest *)o;
+static int __pyx_tp_clear_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;
PyObject* tmp;
tmp = ((PyObject*)p->__pyx_v_self);
p->__pyx_v_self = ((struct __pyx_obj_5_cdec_Hypergraph *)Py_None); Py_INCREF(Py_None);
@@ -4249,17 +24089,14 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_1_kbest(PyObject *o) {
tmp = ((PyObject*)p->__pyx_v_size);
p->__pyx_v_size = Py_None; Py_INCREF(Py_None);
Py_XDECREF(tmp);
- tmp = ((PyObject*)p->__pyx_v_tree);
- p->__pyx_v_tree = ((PyObject*)Py_None); Py_INCREF(Py_None);
- Py_XDECREF(tmp);
return 0;
}
-static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_1_kbest[] = {
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_8_kbest[] = {
{0, 0, 0, 0}
};
-static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_1_kbest = {
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_8_kbest = {
0, /*nb_add*/
0, /*nb_subtract*/
0, /*nb_multiply*/
@@ -4317,7 +24154,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_1_kbest = {
#endif
};
-static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_1_kbest = {
+static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_8_kbest = {
0, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
@@ -4330,13 +24167,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_1_kbest = {
0, /*sq_inplace_repeat*/
};
-static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_1_kbest = {
+static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_8_kbest = {
0, /*mp_length*/
0, /*mp_subscript*/
0, /*mp_ass_subscript*/
};
-static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_1_kbest = {
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_8_kbest = {
#if PY_MAJOR_VERSION < 3
0, /*bf_getreadbuffer*/
#endif
@@ -4357,12 +24194,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_1_kbest = {
#endif
};
-static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_1_kbest = {
+static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_8_kbest = {
PyVarObject_HEAD_INIT(0, 0)
- __Pyx_NAMESTR("_cdec.__pyx_scope_struct_1_kbest"), /*tp_name*/
- sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_1_kbest), /*tp_basicsize*/
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_8_kbest"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest), /*tp_basicsize*/
0, /*tp_itemsize*/
- __pyx_tp_dealloc_5_cdec___pyx_scope_struct_1_kbest, /*tp_dealloc*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_8_kbest, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
@@ -4372,24 +24209,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_1_kbest = {
0, /*reserved*/
#endif
0, /*tp_repr*/
- &__pyx_tp_as_number___pyx_scope_struct_1_kbest, /*tp_as_number*/
- &__pyx_tp_as_sequence___pyx_scope_struct_1_kbest, /*tp_as_sequence*/
- &__pyx_tp_as_mapping___pyx_scope_struct_1_kbest, /*tp_as_mapping*/
+ &__pyx_tp_as_number___pyx_scope_struct_8_kbest, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_8_kbest, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_8_kbest, /*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_1_kbest, /*tp_as_buffer*/
+ &__pyx_tp_as_buffer___pyx_scope_struct_8_kbest, /*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_1_kbest, /*tp_traverse*/
- __pyx_tp_clear_5_cdec___pyx_scope_struct_1_kbest, /*tp_clear*/
+ __pyx_tp_traverse_5_cdec___pyx_scope_struct_8_kbest, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_8_kbest, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
- __pyx_methods_5_cdec___pyx_scope_struct_1_kbest, /*tp_methods*/
+ __pyx_methods_5_cdec___pyx_scope_struct_8_kbest, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
0, /*tp_base*/
@@ -4399,7 +24236,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_1_kbest = {
0, /*tp_dictoffset*/
0, /*tp_init*/
0, /*tp_alloc*/
- __pyx_tp_new_5_cdec___pyx_scope_struct_1_kbest, /*tp_new*/
+ __pyx_tp_new_5_cdec___pyx_scope_struct_8_kbest, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
@@ -4413,48 +24250,263 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_1_kbest = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_2_kbest_tree(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree *p;
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_9_kbest_trees(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
- p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree *)o);
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees *)o);
+ p->__pyx_v_e_tree = 0;
+ p->__pyx_v_f_tree = 0;
p->__pyx_v_self = 0;
- p->__pyx_v_sentence = 0;
p->__pyx_v_size = 0;
return o;
}
-static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_2_kbest_tree(PyObject *o) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree *)o;
+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(((PyObject *)p->__pyx_v_sentence));
Py_XDECREF(p->__pyx_v_size);
(*Py_TYPE(o)->tp_free)(o);
}
-static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_2_kbest_tree(PyObject *o, visitproc v, void *a) {
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_9_kbest_trees(PyObject *o, visitproc v, void *a) {
int e;
- struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree *)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;
+ if (p->__pyx_v_e_tree) {
+ e = (*v)(p->__pyx_v_e_tree, a); if (e) return e;
+ }
+ if (p->__pyx_v_f_tree) {
+ e = (*v)(p->__pyx_v_f_tree, a); if (e) return e;
+ }
if (p->__pyx_v_self) {
e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
}
- if (p->__pyx_v_sentence) {
- e = (*v)(p->__pyx_v_sentence, a); if (e) return e;
- }
if (p->__pyx_v_size) {
e = (*v)(p->__pyx_v_size, a); if (e) return e;
}
return 0;
}
-static int __pyx_tp_clear_5_cdec___pyx_scope_struct_2_kbest_tree(PyObject *o) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree *)o;
+static int __pyx_tp_clear_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;
PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_e_tree);
+ p->__pyx_v_e_tree = ((PyObject*)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_f_tree);
+ p->__pyx_v_f_tree = ((PyObject*)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
tmp = ((PyObject*)p->__pyx_v_self);
p->__pyx_v_self = ((struct __pyx_obj_5_cdec_Hypergraph *)Py_None); Py_INCREF(Py_None);
Py_XDECREF(tmp);
- tmp = ((PyObject*)p->__pyx_v_sentence);
- p->__pyx_v_sentence = ((PyObject*)Py_None); Py_INCREF(Py_None);
+ tmp = ((PyObject*)p->__pyx_v_size);
+ p->__pyx_v_size = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_9_kbest_trees[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_9_kbest_trees = {
+ 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_9_kbest_trees = {
+ 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_9_kbest_trees = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_9_kbest_trees = {
+ #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_9_kbest_trees = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_9_kbest_trees"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_9_kbest_trees, /*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_9_kbest_trees, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_9_kbest_trees, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_9_kbest_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_9_kbest_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_9_kbest_trees, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_9_kbest_trees, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_9_kbest_trees, /*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_9_kbest_trees, /*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_10_kbest_features(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features *)o);
+ p->__pyx_v_fmap = 0;
+ p->__pyx_v_self = 0;
+ p->__pyx_v_size = 0;
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_10_kbest_features(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features *)o;
+ if (p->__pyx_v_fmap) {
+ e = (*v)(((PyObject*)p->__pyx_v_fmap), a); if (e) return e;
+ }
+ if (p->__pyx_v_self) {
+ e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
+ }
+ if (p->__pyx_v_size) {
+ e = (*v)(p->__pyx_v_size, a); if (e) return e;
+ }
+ return 0;
+}
+
+static int __pyx_tp_clear_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;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_fmap);
+ p->__pyx_v_fmap = ((struct __pyx_obj_5_cdec_SparseVector *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_self);
+ p->__pyx_v_self = ((struct __pyx_obj_5_cdec_Hypergraph *)Py_None); Py_INCREF(Py_None);
Py_XDECREF(tmp);
tmp = ((PyObject*)p->__pyx_v_size);
p->__pyx_v_size = Py_None; Py_INCREF(Py_None);
@@ -4462,11 +24514,11 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_2_kbest_tree(PyObject *o) {
return 0;
}
-static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_2_kbest_tree[] = {
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_10_kbest_features[] = {
{0, 0, 0, 0}
};
-static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_2_kbest_tree = {
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_10_kbest_features = {
0, /*nb_add*/
0, /*nb_subtract*/
0, /*nb_multiply*/
@@ -4524,7 +24576,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_2_kbest_tree = {
#endif
};
-static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_2_kbest_tree = {
+static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_10_kbest_features = {
0, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
@@ -4537,13 +24589,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_2_kbest_tree =
0, /*sq_inplace_repeat*/
};
-static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_2_kbest_tree = {
+static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_10_kbest_features = {
0, /*mp_length*/
0, /*mp_subscript*/
0, /*mp_ass_subscript*/
};
-static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_2_kbest_tree = {
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_10_kbest_features = {
#if PY_MAJOR_VERSION < 3
0, /*bf_getreadbuffer*/
#endif
@@ -4564,12 +24616,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_2_kbest_tree = {
#endif
};
-static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_2_kbest_tree = {
+static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_10_kbest_features = {
PyVarObject_HEAD_INIT(0, 0)
- __Pyx_NAMESTR("_cdec.__pyx_scope_struct_2_kbest_tree"), /*tp_name*/
- sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest_tree), /*tp_basicsize*/
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_10_kbest_features"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features), /*tp_basicsize*/
0, /*tp_itemsize*/
- __pyx_tp_dealloc_5_cdec___pyx_scope_struct_2_kbest_tree, /*tp_dealloc*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_10_kbest_features, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
@@ -4579,24 +24631,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_2_kbest_tree = {
0, /*reserved*/
#endif
0, /*tp_repr*/
- &__pyx_tp_as_number___pyx_scope_struct_2_kbest_tree, /*tp_as_number*/
- &__pyx_tp_as_sequence___pyx_scope_struct_2_kbest_tree, /*tp_as_sequence*/
- &__pyx_tp_as_mapping___pyx_scope_struct_2_kbest_tree, /*tp_as_mapping*/
+ &__pyx_tp_as_number___pyx_scope_struct_10_kbest_features, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_10_kbest_features, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_10_kbest_features, /*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_2_kbest_tree, /*tp_as_buffer*/
+ &__pyx_tp_as_buffer___pyx_scope_struct_10_kbest_features, /*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_2_kbest_tree, /*tp_traverse*/
- __pyx_tp_clear_5_cdec___pyx_scope_struct_2_kbest_tree, /*tp_clear*/
+ __pyx_tp_traverse_5_cdec___pyx_scope_struct_10_kbest_features, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_10_kbest_features, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
- __pyx_methods_5_cdec___pyx_scope_struct_2_kbest_tree, /*tp_methods*/
+ __pyx_methods_5_cdec___pyx_scope_struct_10_kbest_features, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
0, /*tp_base*/
@@ -4606,7 +24658,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_2_kbest_tree = {
0, /*tp_dictoffset*/
0, /*tp_init*/
0, /*tp_alloc*/
- __pyx_tp_new_5_cdec___pyx_scope_struct_2_kbest_tree, /*tp_new*/
+ __pyx_tp_new_5_cdec___pyx_scope_struct_10_kbest_features, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
@@ -4620,52 +24672,1620 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_2_kbest_tree = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_3_sample(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample *p;
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_11_sample(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
- p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample *)o);
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *)o);
p->__pyx_v_self = 0;
- p->__pyx_v_sentence = 0;
return o;
}
-static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_3_sample(PyObject *o) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample *)o;
+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_XDECREF(((PyObject *)p->__pyx_v_sentence));
(*Py_TYPE(o)->tp_free)(o);
}
-static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_3_sample(PyObject *o, visitproc v, void *a) {
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_11_sample(PyObject *o, visitproc v, void *a) {
int e;
- struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample *)o;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *)o;
if (p->__pyx_v_self) {
e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
}
- if (p->__pyx_v_sentence) {
- e = (*v)(p->__pyx_v_sentence, a); if (e) return e;
+ return 0;
+}
+
+static int __pyx_tp_clear_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;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_self);
+ p->__pyx_v_self = ((struct __pyx_obj_5_cdec_Hypergraph *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_11_sample[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_11_sample = {
+ 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_11_sample = {
+ 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_11_sample = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_11_sample = {
+ #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_11_sample = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_11_sample"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_11_sample, /*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_11_sample, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_11_sample, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_11_sample, /*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_11_sample, /*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_11_sample, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_11_sample, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_11_sample, /*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_11_sample, /*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_12___get__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_12___get__ *)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));
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_12___get__(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;
+ 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_3_sample(PyObject *o) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample *)o;
+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;
PyObject* tmp;
tmp = ((PyObject*)p->__pyx_v_self);
p->__pyx_v_self = ((struct __pyx_obj_5_cdec_Hypergraph *)Py_None); Py_INCREF(Py_None);
Py_XDECREF(tmp);
- tmp = ((PyObject*)p->__pyx_v_sentence);
- p->__pyx_v_sentence = ((PyObject*)Py_None); Py_INCREF(Py_None);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_12___get__[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_12___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_12___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_12___get__ = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_12___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_12___get__ = {
+ 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*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_12___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_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*/
+ 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*/
+ 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*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_12___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_12___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_13___get__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *)o);
+ p->__pyx_v_self = 0;
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_13___get__(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_13___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_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;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_self);
+ p->__pyx_v_self = ((struct __pyx_obj_5_cdec_Hypergraph *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_13___get__[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_13___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_13___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_13___get__ = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_13___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_13___get__ = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_13___get__"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_13___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_13___get__, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_13___get__, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_13___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_13___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_13___get__, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_13___get__, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_13___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_13___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_14___get__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *)o);
+ p->__pyx_v_self = 0;
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_14___get__(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_14___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_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);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_14___get__[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_14___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_14___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_14___get__ = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_14___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_14___get__ = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_14___get__"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_14___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_14___get__, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_14___get__, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_14___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_14___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_14___get__, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_14___get__, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_14___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_14___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_15___get__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *)o);
+ p->__pyx_v_self = 0;
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_15___get__(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_15___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_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);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_15___get__[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_15___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_15___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_15___get__ = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_15___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_15___get__ = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_15___get__"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_15___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_15___get__, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_15___get__, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_15___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_15___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_15___get__, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_15___get__, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_15___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_15___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_16___get__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *)o);
+ p->__pyx_v_self = 0;
+ return o;
+}
+
+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_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_16___get__(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_16___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_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;
+ 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_16___get__[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_16___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_16___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_16___get__ = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_16___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_16___get__ = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_16___get__"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_16___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_16___get__, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_16___get__, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_16___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_16___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_16___get__, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_16___get__, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_16___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_16___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_17___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_17___iter__ *)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));
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_17___iter__(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;
+ 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;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_self);
+ p->__pyx_v_self = ((struct __pyx_obj_5_cdec_Lattice *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_17___iter__[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_17___iter__ = {
+ 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___iter__ = {
+ 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___iter__ = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_17___iter__ = {
+ #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___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*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_17___iter__, /*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___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*/
+ 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*/
+ 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*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_17___iter__, /*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___iter__, /*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_todot(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_18_todot *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_18_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));
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_18_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;
+ 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;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_self);
+ p->__pyx_v_self = ((struct __pyx_obj_5_cdec_Lattice *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_18_todot[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_18_todot = {
+ 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_18_todot = {
+ 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_18_todot = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_18_todot = {
+ #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_18_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*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_18_todot, /*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_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*/
+ 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*/
+ 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*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_18_todot, /*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_18_todot, /*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_19_lines(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines *)o);
+ p->__pyx_outer_scope = 0;
+ p->__pyx_v_delta = 0;
+ p->__pyx_v_i = 0;
+ p->__pyx_v_label = 0;
+ p->__pyx_v_weight = 0;
+ p->__pyx_t_1 = 0;
+ p->__pyx_t_3 = 0;
+ 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);
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_19_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;
+ if (p->__pyx_outer_scope) {
+ e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
+ }
+ if (p->__pyx_v_delta) {
+ e = (*v)(p->__pyx_v_delta, a); if (e) return e;
+ }
+ if (p->__pyx_v_i) {
+ e = (*v)(p->__pyx_v_i, a); if (e) return e;
+ }
+ if (p->__pyx_v_label) {
+ e = (*v)(p->__pyx_v_label, a); if (e) return e;
+ }
+ if (p->__pyx_v_weight) {
+ e = (*v)(p->__pyx_v_weight, a); if (e) return e;
+ }
+ if (p->__pyx_t_1) {
+ e = (*v)(p->__pyx_t_1, a); if (e) return e;
+ }
+ if (p->__pyx_t_3) {
+ e = (*v)(p->__pyx_t_3, a); if (e) return e;
+ }
+ 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;
+ 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);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_delta);
+ p->__pyx_v_delta = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_i);
+ p->__pyx_v_i = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_label);
+ p->__pyx_v_label = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_weight);
+ p->__pyx_v_weight = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_t_1);
+ p->__pyx_t_1 = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_t_3);
+ p->__pyx_t_3 = Py_None; Py_INCREF(Py_None);
Py_XDECREF(tmp);
return 0;
}
-static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_3_sample[] = {
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_19_lines[] = {
{0, 0, 0, 0}
};
-static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_3_sample = {
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_19_lines = {
0, /*nb_add*/
0, /*nb_subtract*/
0, /*nb_multiply*/
@@ -4723,7 +26343,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_3_sample = {
#endif
};
-static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_3_sample = {
+static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_19_lines = {
0, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
@@ -4736,13 +26356,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_3_sample = {
0, /*sq_inplace_repeat*/
};
-static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_3_sample = {
+static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_19_lines = {
0, /*mp_length*/
0, /*mp_subscript*/
0, /*mp_ass_subscript*/
};
-static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_3_sample = {
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_19_lines = {
#if PY_MAJOR_VERSION < 3
0, /*bf_getreadbuffer*/
#endif
@@ -4763,12 +26383,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_3_sample = {
#endif
};
-static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_3_sample = {
+static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_19_lines = {
PyVarObject_HEAD_INIT(0, 0)
- __Pyx_NAMESTR("_cdec.__pyx_scope_struct_3_sample"), /*tp_name*/
- sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_3_sample), /*tp_basicsize*/
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_19_lines"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_19_lines), /*tp_basicsize*/
0, /*tp_itemsize*/
- __pyx_tp_dealloc_5_cdec___pyx_scope_struct_3_sample, /*tp_dealloc*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_19_lines, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
@@ -4778,24 +26398,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_3_sample = {
0, /*reserved*/
#endif
0, /*tp_repr*/
- &__pyx_tp_as_number___pyx_scope_struct_3_sample, /*tp_as_number*/
- &__pyx_tp_as_sequence___pyx_scope_struct_3_sample, /*tp_as_sequence*/
- &__pyx_tp_as_mapping___pyx_scope_struct_3_sample, /*tp_as_mapping*/
+ &__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*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
- &__pyx_tp_as_buffer___pyx_scope_struct_3_sample, /*tp_as_buffer*/
+ &__pyx_tp_as_buffer___pyx_scope_struct_19_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_3_sample, /*tp_traverse*/
- __pyx_tp_clear_5_cdec___pyx_scope_struct_3_sample, /*tp_clear*/
+ __pyx_tp_traverse_5_cdec___pyx_scope_struct_19_lines, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_19_lines, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
- __pyx_methods_5_cdec___pyx_scope_struct_3_sample, /*tp_methods*/
+ __pyx_methods_5_cdec___pyx_scope_struct_19_lines, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
0, /*tp_base*/
@@ -4805,7 +26425,1042 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_3_sample = {
0, /*tp_dictoffset*/
0, /*tp_init*/
0, /*tp_alloc*/
- __pyx_tp_new_5_cdec___pyx_scope_struct_3_sample, /*tp_new*/
+ __pyx_tp_new_5_cdec___pyx_scope_struct_19_lines, /*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_20___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_20___iter__ *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_20___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);
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_20___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;
+ if (p->__pyx_v_i) {
+ e = (*v)(p->__pyx_v_i, a); if (e) return e;
+ }
+ if (p->__pyx_v_self) {
+ e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
+ }
+ if (p->__pyx_t_1) {
+ e = (*v)(p->__pyx_t_1, a); if (e) return e;
+ }
+ 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;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_i);
+ p->__pyx_v_i = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_self);
+ p->__pyx_v_self = ((struct __pyx_obj_5_cdec_SufficientStats *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_t_1);
+ p->__pyx_t_1 = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_20___iter__[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_20___iter__ = {
+ 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_20___iter__ = {
+ 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_20___iter__ = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_20___iter__ = {
+ #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_20___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*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_20___iter__, /*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_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*/
+ 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*/
+ 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*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_20___iter__, /*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_20___iter__, /*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_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_21___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));
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+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_21___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_21___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;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_self);
+ p->__pyx_v_self = ((struct __pyx_obj_5_cdec_CandidateSet *)Py_None); Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_21___iter__[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_21___iter__ = {
+ 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_21___iter__ = {
+ 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_21___iter__ = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_21___iter__ = {
+ #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_21___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*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_21___iter__, /*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_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_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_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_21___iter__, /*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_21___iter__, /*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_22__make_config(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_22__make_config *)o);
+ p->__pyx_v_config = 0;
+ p->__pyx_v_info = 0;
+ p->__pyx_v_key = 0;
+ p->__pyx_v_name = 0;
+ p->__pyx_v_value = 0;
+ p->__pyx_t_0 = 0;
+ p->__pyx_t_1 = 0;
+ 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);
+ (*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) {
+ 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;
+ if (p->__pyx_v_config) {
+ e = (*v)(p->__pyx_v_config, a); if (e) return e;
+ }
+ if (p->__pyx_v_info) {
+ e = (*v)(p->__pyx_v_info, a); if (e) return e;
+ }
+ if (p->__pyx_v_key) {
+ e = (*v)(p->__pyx_v_key, a); if (e) return e;
+ }
+ if (p->__pyx_v_name) {
+ e = (*v)(p->__pyx_v_name, a); if (e) return e;
+ }
+ if (p->__pyx_v_value) {
+ e = (*v)(p->__pyx_v_value, a); if (e) return e;
+ }
+ if (p->__pyx_t_0) {
+ e = (*v)(p->__pyx_t_0, a); if (e) return e;
+ }
+ if (p->__pyx_t_1) {
+ e = (*v)(p->__pyx_t_1, a); if (e) return e;
+ }
+ 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;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_config);
+ p->__pyx_v_config = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_info);
+ p->__pyx_v_info = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_key);
+ p->__pyx_v_key = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_name);
+ p->__pyx_v_name = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_value);
+ p->__pyx_v_value = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_t_0);
+ p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_t_1);
+ p->__pyx_t_1 = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_22__make_config[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_22__make_config = {
+ 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_22__make_config = {
+ 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_22__make_config = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_22__make_config = {
+ #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_22__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*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_22__make_config, /*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_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*/
+ 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*/
+ 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*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_22__make_config, /*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_22__make_config, /*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_23___cinit__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_23___cinit__ *)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);
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_23___cinit__(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;
+ 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;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_v_config);
+ p->__pyx_v_config = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_23___cinit__[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_23___cinit__ = {
+ 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_23___cinit__ = {
+ 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_23___cinit__ = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_23___cinit__ = {
+ #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_23___cinit__ = {
+ 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*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_23___cinit__, /*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_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*/
+ 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*/
+ 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*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_23___cinit__, /*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_23___cinit__, /*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_24_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_24_genexpr *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_24_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);
+ (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_24_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;
+ if (p->__pyx_outer_scope) {
+ e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
+ }
+ if (p->__pyx_v_kv) {
+ e = (*v)(p->__pyx_v_kv, a); if (e) return e;
+ }
+ if (p->__pyx_t_0) {
+ e = (*v)(p->__pyx_t_0, a); if (e) return e;
+ }
+ 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;
+ 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);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_v_kv);
+ p->__pyx_v_kv = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ tmp = ((PyObject*)p->__pyx_t_0);
+ p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
+ Py_XDECREF(tmp);
+ return 0;
+}
+
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_24_genexpr[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_24_genexpr = {
+ 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_24_genexpr = {
+ 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_24_genexpr = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_24_genexpr = {
+ #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_24_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*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_24_genexpr, /*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_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*/
+ 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*/
+ 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*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_24_genexpr, /*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_24_genexpr, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
@@ -4838,36 +27493,144 @@ static struct PyModuleDef __pyx_moduledef = {
#endif
static __Pyx_StringTabEntry __pyx_string_tab[] = {
+ {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
+ {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
+ {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
+ {&__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_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_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_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_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_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_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_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_n_s_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 0, 1, 1},
+ {&__pyx_n_s_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 1, 1},
+ {&__pyx_kp_s_58, __pyx_k_58, sizeof(__pyx_k_58), 0, 0, 1, 0},
+ {&__pyx_kp_s_64, __pyx_k_64, sizeof(__pyx_k_64), 0, 0, 1, 0},
+ {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
+ {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
+ {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
+ {&__pyx_n_s__BLEU, __pyx_k__BLEU, sizeof(__pyx_k__BLEU), 0, 0, 1, 1},
+ {&__pyx_n_s__CER, __pyx_k__CER, sizeof(__pyx_k__CER), 0, 0, 1, 1},
{&__pyx_n_s__Exception, __pyx_k__Exception, sizeof(__pyx_k__Exception), 0, 0, 1, 1},
+ {&__pyx_n_s__IBM_BLEU, __pyx_k__IBM_BLEU, sizeof(__pyx_k__IBM_BLEU), 0, 0, 1, 1},
+ {&__pyx_n_s__IndexError, __pyx_k__IndexError, sizeof(__pyx_k__IndexError), 0, 0, 1, 1},
+ {&__pyx_n_s__InvalidConfig, __pyx_k__InvalidConfig, sizeof(__pyx_k__InvalidConfig), 0, 0, 1, 1},
{&__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},
+ {&__pyx_n_s____class__, __pyx_k____class__, sizeof(__pyx_k____class__), 0, 0, 1, 1},
{&__pyx_n_s____enter__, __pyx_k____enter__, sizeof(__pyx_k____enter__), 0, 0, 1, 1},
{&__pyx_n_s____exit__, __pyx_k____exit__, sizeof(__pyx_k____exit__), 0, 0, 1, 1},
+ {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
{&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
+ {&__pyx_n_s____name__, __pyx_k____name__, sizeof(__pyx_k____name__), 0, 0, 1, 1},
{&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
{&__pyx_n_s___cdec, __pyx_k___cdec, sizeof(__pyx_k___cdec), 0, 0, 1, 1},
+ {&__pyx_n_s___make_config, __pyx_k___make_config, sizeof(__pyx_k___make_config), 0, 0, 1, 1},
+ {&__pyx_n_s___phrase, __pyx_k___phrase, sizeof(__pyx_k___phrase), 0, 0, 1, 1},
+ {&__pyx_n_s___sa, __pyx_k___sa, sizeof(__pyx_k___sa), 0, 0, 1, 1},
+ {&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1},
+ {&__pyx_n_s__beam_alpha, __pyx_k__beam_alpha, sizeof(__pyx_k__beam_alpha), 0, 0, 1, 1},
+ {&__pyx_n_s__cat, __pyx_k__cat, sizeof(__pyx_k__cat), 0, 0, 1, 1},
{&__pyx_n_s__config, __pyx_k__config, sizeof(__pyx_k__config), 0, 0, 1, 1},
- {&__pyx_n_s__decode, __pyx_k__decode, sizeof(__pyx_k__decode), 0, 0, 1, 1},
- {&__pyx_n_s__decoder, __pyx_k__decoder, sizeof(__pyx_k__decoder), 0, 0, 1, 1},
+ {&__pyx_n_s__config_str, __pyx_k__config_str, sizeof(__pyx_k__config_str), 0, 0, 1, 1},
+ {&__pyx_n_s__csplit, __pyx_k__csplit, sizeof(__pyx_k__csplit), 0, 0, 1, 1},
+ {&__pyx_n_s__delta, __pyx_k__delta, sizeof(__pyx_k__delta), 0, 0, 1, 1},
+ {&__pyx_n_s__density, __pyx_k__density, sizeof(__pyx_k__density), 0, 0, 1, 1},
+ {&__pyx_n_s__dot, __pyx_k__dot, sizeof(__pyx_k__dot), 0, 0, 1, 1},
+ {&__pyx_n_s__e, __pyx_k__e, sizeof(__pyx_k__e), 0, 0, 1, 1},
{&__pyx_n_s__encode, __pyx_k__encode, sizeof(__pyx_k__encode), 0, 0, 1, 1},
+ {&__pyx_n_s__encoding, __pyx_k__encoding, sizeof(__pyx_k__encoding), 0, 0, 1, 1},
+ {&__pyx_n_s__enumerate, __pyx_k__enumerate, sizeof(__pyx_k__enumerate), 0, 0, 1, 1},
{&__pyx_n_s__eval, __pyx_k__eval, sizeof(__pyx_k__eval), 0, 0, 1, 1},
+ {&__pyx_n_s__evaluate, __pyx_k__evaluate, sizeof(__pyx_k__evaluate), 0, 0, 1, 1},
+ {&__pyx_n_s__evaluator, __pyx_k__evaluator, sizeof(__pyx_k__evaluator), 0, 0, 1, 1},
+ {&__pyx_n_s__f, __pyx_k__f, sizeof(__pyx_k__f), 0, 0, 1, 1},
+ {&__pyx_n_s__formalism, __pyx_k__formalism, sizeof(__pyx_k__formalism), 0, 0, 1, 1},
+ {&__pyx_n_s__format, __pyx_k__format, sizeof(__pyx_k__format), 0, 0, 1, 1},
+ {&__pyx_n_s__fst, __pyx_k__fst, sizeof(__pyx_k__fst), 0, 0, 1, 1},
+ {&__pyx_n_s__genexpr, __pyx_k__genexpr, sizeof(__pyx_k__genexpr), 0, 0, 1, 1},
+ {&__pyx_n_s__get, __pyx_k__get, sizeof(__pyx_k__get), 0, 0, 1, 1},
{&__pyx_n_s__grammar, __pyx_k__grammar, sizeof(__pyx_k__grammar), 0, 0, 1, 1},
+ {&__pyx_n_s__hyp, __pyx_k__hyp, sizeof(__pyx_k__hyp), 0, 0, 1, 1},
+ {&__pyx_n_s__hypergraph, __pyx_k__hypergraph, sizeof(__pyx_k__hypergraph), 0, 0, 1, 1},
+ {&__pyx_n_s__i, __pyx_k__i, sizeof(__pyx_k__i), 0, 0, 1, 1},
+ {&__pyx_n_s__in_edges, __pyx_k__in_edges, sizeof(__pyx_k__in_edges), 0, 0, 1, 1},
+ {&__pyx_n_s__info, __pyx_k__info, sizeof(__pyx_k__info), 0, 0, 1, 1},
+ {&__pyx_n_s__inp, __pyx_k__inp, sizeof(__pyx_k__inp), 0, 0, 1, 1},
+ {&__pyx_n_s__items, __pyx_k__items, sizeof(__pyx_k__items), 0, 0, 1, 1},
+ {&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
+ {&__pyx_n_s__k, __pyx_k__k, sizeof(__pyx_k__k), 0, 0, 1, 1},
+ {&__pyx_n_s__key, __pyx_k__key, sizeof(__pyx_k__key), 0, 0, 1, 1},
+ {&__pyx_n_s__label, __pyx_k__label, sizeof(__pyx_k__label), 0, 0, 1, 1},
+ {&__pyx_n_s__lexalign, __pyx_k__lexalign, sizeof(__pyx_k__lexalign), 0, 0, 1, 1},
+ {&__pyx_n_s__lextrans, __pyx_k__lextrans, sizeof(__pyx_k__lextrans), 0, 0, 1, 1},
+ {&__pyx_n_s__lhs, __pyx_k__lhs, sizeof(__pyx_k__lhs), 0, 0, 1, 1},
+ {&__pyx_n_s__lines, __pyx_k__lines, sizeof(__pyx_k__lines), 0, 0, 1, 1},
+ {&__pyx_n_s__name, __pyx_k__name, sizeof(__pyx_k__name), 0, 0, 1, 1},
{&__pyx_n_s__open, __pyx_k__open, sizeof(__pyx_k__open), 0, 0, 1, 1},
- {&__pyx_n_s__plf_tuple, __pyx_k__plf_tuple, sizeof(__pyx_k__plf_tuple), 0, 0, 1, 1},
+ {&__pyx_n_s__pb, __pyx_k__pb, sizeof(__pyx_k__pb), 0, 0, 1, 1},
+ {&__pyx_n_s__phrase, __pyx_k__phrase, sizeof(__pyx_k__phrase), 0, 0, 1, 1},
+ {&__pyx_n_s__plf, __pyx_k__plf, sizeof(__pyx_k__plf), 0, 0, 1, 1},
{&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
+ {&__pyx_n_s__ref, __pyx_k__ref, sizeof(__pyx_k__ref), 0, 0, 1, 1},
+ {&__pyx_n_s__refs, __pyx_k__refs, sizeof(__pyx_k__refs), 0, 0, 1, 1},
+ {&__pyx_n_s__replace, __pyx_k__replace, sizeof(__pyx_k__replace), 0, 0, 1, 1},
+ {&__pyx_n_s__rhs, __pyx_k__rhs, sizeof(__pyx_k__rhs), 0, 0, 1, 1},
+ {&__pyx_n_s__rules, __pyx_k__rules, sizeof(__pyx_k__rules), 0, 0, 1, 1},
+ {&__pyx_n_s__scfg, __pyx_k__scfg, sizeof(__pyx_k__scfg), 0, 0, 1, 1},
+ {&__pyx_n_s__score, __pyx_k__score, sizeof(__pyx_k__score), 0, 0, 1, 1},
+ {&__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__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},
{&__pyx_n_s__strip, __pyx_k__strip, sizeof(__pyx_k__strip), 0, 0, 1, 1},
+ {&__pyx_n_s__super, __pyx_k__super, sizeof(__pyx_k__super), 0, 0, 1, 1},
+ {&__pyx_n_s__tagger, __pyx_k__tagger, sizeof(__pyx_k__tagger), 0, 0, 1, 1},
{&__pyx_n_s__utf8, __pyx_k__utf8, sizeof(__pyx_k__utf8), 0, 0, 1, 1},
+ {&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1},
+ {&__pyx_n_s__weight, __pyx_k__weight, sizeof(__pyx_k__weight), 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 = 12; __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[0]; __pyx_lineno = 25; __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[0]; __pyx_lineno = 35; __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 = 53; __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[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __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;}
return 0;
__pyx_L1_error:;
return -1;
@@ -4877,109 +27640,361 @@ static int __Pyx_InitCachedConstants(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
- /* "_cdec.pyx":53
- *
- * def read_weights(self, cfg):
- * with open(cfg) as fp: # <<<<<<<<<<<<<<
- * for line in fp:
- * fname, value = line.split()
+ /* "_cdec.pyx":9
+ * cdef bytes ret
+ * if isinstance(data, unicode):
+ * ret = data.encode('utf8') # <<<<<<<<<<<<<<
+ * elif isinstance(data, str):
+ * ret = data
*/
- __pyx_k_tuple_1 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_1);
- __Pyx_INCREF(Py_None);
- PyTuple_SET_ITEM(__pyx_k_tuple_1, 0, Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_INCREF(Py_None);
- PyTuple_SET_ITEM(__pyx_k_tuple_1, 1, Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_INCREF(Py_None);
- PyTuple_SET_ITEM(__pyx_k_tuple_1, 2, Py_None);
- __Pyx_GIVEREF(Py_None);
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_1));
-
- /* "_cdec.pyx":62
- * if grammar:
- * self.dec.SetSentenceGrammarFromString(string(<char *> grammar))
- * inp = sentence.strip().encode('utf8') # <<<<<<<<<<<<<<
- * cdef decoder.BasicObserver observer = decoder.BasicObserver()
- * self.dec.Decode(string(<char *>inp), &observer)
- */
- __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_k_tuple_2);
__Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_n_s__utf8));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2));
- /* "_cdec.pyx":85
- * hypergraph.ViterbiESentence(self.hg[0], &trans)
- * cdef str sentence = GetString(trans).c_str()
- * return sentence.decode('utf8') # <<<<<<<<<<<<<<
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":89
+ * elif op == 3: # !=
+ * return not (x == y)
+ * raise NotImplemented('comparison not implemented for SparseVector') # <<<<<<<<<<<<<<
*
- * def viterbi_tree(self):
+ * def __len__(self):
*/
- __pyx_k_tuple_3 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_3);
- __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
- PyTuple_SET_ITEM(__pyx_k_tuple_3, 0, ((PyObject *)__pyx_n_s__utf8));
- __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_3));
+ __pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_5);
+ __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
+ PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, ((PyObject *)__pyx_kp_s_4));
+ __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5));
- /* "_cdec.pyx":90
- * assert (self.hg != NULL)
- * cdef str tree = hypergraph.ViterbiETree(self.hg[0]).c_str()
- * return tree.decode('utf8') # <<<<<<<<<<<<<<
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":6
*
- * def kbest(self, size):
+ * def _phrase(phrase):
+ * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) # <<<<<<<<<<<<<<
+ *
+ * cdef class NT:
*/
- __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_4);
+ __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_6);
__Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
- PyTuple_SET_ITEM(__pyx_k_tuple_4, 0, ((PyObject *)__pyx_n_s__utf8));
+ PyTuple_SET_ITEM(__pyx_k_tuple_6, 0, ((PyObject *)__pyx_n_s__utf8));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6));
- /* "_cdec.pyx":102
- * if not derivation: break
- * tree = GetString(derivation._yield).c_str()
- * yield tree.decode('utf8') # <<<<<<<<<<<<<<
- * del derivations
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":212
+ * trule = convert_rule(trule)
+ * elif not isinstance(trule, TRule):
+ * raise ValueError('the grammar should contain TRule objects') # <<<<<<<<<<<<<<
+ * _g.AddRule((<TRule> trule).rule[0])
+ */
+ __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_14);
+ __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
+ PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, ((PyObject *)__pyx_kp_s_13));
+ __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_13));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":191
+ * elif op == 3: # !=
+ * return not (x == y)
+ * raise NotImplemented('comparison not implemented for HypergraphEdge') # <<<<<<<<<<<<<<
*
+ * cdef class HypergraphNode:
*/
- __pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_5);
+ __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));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":228
+ * 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_GOTREF(__pyx_k_tuple_21);
__Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
- PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, ((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_GIVEREF(((PyObject *)__pyx_k_tuple_5));
-
- /* "_cdec.pyx":115
- * if not derivation: break
- * sentence = GetString(derivation._yield).c_str()
- * yield sentence.decode('utf8') # <<<<<<<<<<<<<<
- * del derivations
- *
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":24
+ * def __getitem__(self, int index):
+ * if not 0 <= index < len(self):
+ * raise IndexError('lattice index out of range') # <<<<<<<<<<<<<<
+ * arcs = []
+ * cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index]
*/
- __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_6);
+ __pyx_k_tuple_24 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_24)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_24);
+ __Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
+ PyTuple_SET_ITEM(__pyx_k_tuple_24, 0, ((PyObject *)__pyx_kp_s_23));
+ __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_24));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":37
+ * def __setitem__(self, int index, tuple arcs):
+ * if not 0 <= index < len(self):
+ * raise IndexError('lattice index out of range') # <<<<<<<<<<<<<<
+ * cdef lattice.LatticeArc* arc
+ * for (label, cost, dist2next) in arcs:
+ */
+ __pyx_k_tuple_25 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_25);
+ __Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
+ PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, ((PyObject *)__pyx_kp_s_23));
+ __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":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_6, 0, ((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_6));
-
- /* "_cdec.pyx":132
- * for k in range(hypos.size()):
- * sentence = GetString(hypos[0][k].words).c_str()
- * yield sentence.decode('utf8') # <<<<<<<<<<<<<<
- * del hypos
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_26));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":64
+ * 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_INCREF(((PyObject *)__pyx_kp_s_31));
+ PyTuple_SET_ITEM(__pyx_k_tuple_33, 0, ((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));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":58
*
+ * def todot(self):
+ * 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_INCREF(((PyObject *)__pyx_n_s__i));
+ PyTuple_SET_ITEM(__pyx_k_tuple_36, 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));
+ __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));
+ __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));
+ __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;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":67
+ * yield '%d [shape=doublecircle]' % len(self)
+ * yield '}'
+ * return '\n'.join(lines()).encode('utf8') # <<<<<<<<<<<<<<
*/
- __pyx_k_tuple_7 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_7);
+ __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_INCREF(((PyObject *)__pyx_n_s__utf8));
- PyTuple_SET_ITEM(__pyx_k_tuple_7, 0, ((PyObject *)__pyx_n_s__utf8));
+ PyTuple_SET_ITEM(__pyx_k_tuple_40, 0, ((PyObject *)__pyx_n_s__utf8));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_40));
+
+ /* "/Users/vchahun/Sandbox/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));
+
+ /* "/Users/vchahun/Sandbox/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));
+
+ /* "_cdec.pyx":50
+ * """
+ * 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_INCREF(((PyObject *)__pyx_n_s__formalism));
+ PyTuple_SET_ITEM(__pyx_k_tuple_47, 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);
+ __Pyx_GIVEREF(Py_None);
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_47));
+
+ /* "_cdec.pyx":90
+ * with open(weights) as fp:
+ * for line in fp:
+ * if line.strip().startswith('#'): continue # <<<<<<<<<<<<<<
+ * fname, value = line.split()
+ * self.weights[fname.strip()] = float(value)
+ */
+ __pyx_k_tuple_51 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_51);
+ __Pyx_INCREF(((PyObject *)__pyx_kp_s_50));
+ PyTuple_SET_ITEM(__pyx_k_tuple_51, 0, ((PyObject *)__pyx_kp_s_50));
+ __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_50));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51));
+
+ /* "_cdec.pyx":88
+ *
+ * def read_weights(self, weights):
+ * with open(weights) as fp: # <<<<<<<<<<<<<<
+ * for line in fp:
+ * if line.strip().startswith('#'): continue
+ */
+ __pyx_k_tuple_52 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_52);
+ __Pyx_INCREF(Py_None);
+ PyTuple_SET_ITEM(__pyx_k_tuple_52, 0, Py_None);
+ __Pyx_GIVEREF(Py_None);
+ __Pyx_INCREF(Py_None);
+ PyTuple_SET_ITEM(__pyx_k_tuple_52, 1, Py_None);
+ __Pyx_GIVEREF(Py_None);
+ __Pyx_INCREF(Py_None);
+ PyTuple_SET_ITEM(__pyx_k_tuple_52, 2, Py_None);
+ __Pyx_GIVEREF(Py_None);
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_52));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5
+ * import cdec.sa._sa as _sa
+ *
+ * def _phrase(phrase): # <<<<<<<<<<<<<<
+ * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase)
+ *
+ */
+ __pyx_k_tuple_56 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_56)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_56);
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__phrase));
+ PyTuple_SET_ITEM(__pyx_k_tuple_56, 0, ((PyObject *)__pyx_n_s__phrase));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__phrase));
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__genexpr));
+ PyTuple_SET_ITEM(__pyx_k_tuple_56, 1, ((PyObject *)__pyx_n_s__genexpr));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__genexpr));
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__genexpr));
+ PyTuple_SET_ITEM(__pyx_k_tuple_56, 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;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":190
+ * 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_INCREF(((PyObject *)__pyx_n_s__IBM_BLEU));
+ PyTuple_SET_ITEM(__pyx_k_tuple_59, 0, ((PyObject *)__pyx_n_s__IBM_BLEU));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IBM_BLEU));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_59));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":191
+ *
+ * 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_INCREF(((PyObject *)__pyx_n_s__TER));
+ PyTuple_SET_ITEM(__pyx_k_tuple_60, 0, ((PyObject *)__pyx_n_s__TER));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__TER));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":192
+ * 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_INCREF(((PyObject *)__pyx_n_s__CER));
+ PyTuple_SET_ITEM(__pyx_k_tuple_61, 0, ((PyObject *)__pyx_n_s__CER));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CER));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61));
+
+ /* "_cdec.pyx":28
+ * class ParseFailed(Exception): pass
+ *
+ * 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_INCREF(((PyObject *)__pyx_n_s__config));
+ PyTuple_SET_ITEM(__pyx_k_tuple_62, 0, ((PyObject *)__pyx_n_s__config));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__config));
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__key));
+ PyTuple_SET_ITEM(__pyx_k_tuple_62, 1, ((PyObject *)__pyx_n_s__key));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__key));
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__value));
+ PyTuple_SET_ITEM(__pyx_k_tuple_62, 2, ((PyObject *)__pyx_n_s__value));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__value));
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__name));
+ PyTuple_SET_ITEM(__pyx_k_tuple_62, 3, ((PyObject *)__pyx_n_s__name));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name));
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__info));
+ PyTuple_SET_ITEM(__pyx_k_tuple_62, 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_RefNannyFinishContext();
return 0;
__pyx_L1_error:;
@@ -4989,6 +28004,9 @@ static int __Pyx_InitCachedConstants(void) {
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;
@@ -5005,6 +28023,7 @@ PyMODINIT_FUNC PyInit__cdec(void)
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
+ PyObject *__pyx_t_4 = NULL;
__Pyx_RefNannyDeclarations
#if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
@@ -5047,6 +28066,9 @@ PyMODINIT_FUNC PyInit__cdec(void)
#endif
__pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ #if CYTHON_COMPILING_IN_PYPY
+ Py_INCREF(__pyx_b);
+ #endif
if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
/*--- Initialize various global constants etc. ---*/
if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -5061,75 +28083,293 @@ PyMODINIT_FUNC PyInit__cdec(void)
/*--- Variable export code ---*/
/*--- Function export code ---*/
/*--- Type init code ---*/
- if (PyType_Ready(&__pyx_type_5_cdec_Weights) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "Weights", (PyObject *)&__pyx_type_5_cdec_Weights) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_ptype_5_cdec_Weights = &__pyx_type_5_cdec_Weights;
- if (PyType_Ready(&__pyx_type_5_cdec_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __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 = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_ptype_5_cdec_Decoder = &__pyx_type_5_cdec_Decoder;
- if (PyType_Ready(&__pyx_type_5_cdec_Hypergraph) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "Hypergraph", (PyObject *)&__pyx_type_5_cdec_Hypergraph) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec_DenseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "DenseVector", (PyObject *)&__pyx_type_5_cdec_DenseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec_DenseVector = &__pyx_type_5_cdec_DenseVector;
+ if (PyType_Ready(&__pyx_type_5_cdec_SparseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "SparseVector", (PyObject *)&__pyx_type_5_cdec_SparseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec_SparseVector = &__pyx_type_5_cdec_SparseVector;
+ if (PyType_Ready(&__pyx_type_5_cdec_NT) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "NT", (PyObject *)&__pyx_type_5_cdec_NT) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec_NT = &__pyx_type_5_cdec_NT;
+ if (PyType_Ready(&__pyx_type_5_cdec_NTRef) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "NTRef", (PyObject *)&__pyx_type_5_cdec_NTRef) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec_NTRef = &__pyx_type_5_cdec_NTRef;
+ if (PyType_Ready(&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "TRule", (PyObject *)&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec_TRule = &__pyx_type_5_cdec_TRule;
+ __pyx_type_5_cdec_MRule.tp_base = __pyx_ptype_5_cdec_TRule;
+ if (PyType_Ready(&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "MRule", (PyObject *)&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec_MRule = &__pyx_type_5_cdec_MRule;
+ if (PyType_Ready(&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "Grammar", (PyObject *)&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec_Grammar = &__pyx_type_5_cdec_Grammar;
+ __pyx_type_5_cdec_TextGrammar.tp_base = __pyx_ptype_5_cdec_Grammar;
+ if (PyType_Ready(&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "TextGrammar", (PyObject *)&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec_TextGrammar = &__pyx_type_5_cdec_TextGrammar;
+ if (PyType_Ready(&__pyx_type_5_cdec_Hypergraph) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "Hypergraph", (PyObject *)&__pyx_type_5_cdec_Hypergraph) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec_Hypergraph = &__pyx_type_5_cdec_Hypergraph;
- if (PyType_Ready(&__pyx_type_5_cdec_Lattice) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "Lattice", (PyObject *)&__pyx_type_5_cdec_Lattice) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __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;}
+ __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;}
+ __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 (__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___pyx_scope_struct____iter__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec_Candidate) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "Candidate", (PyObject *)&__pyx_type_5_cdec_Candidate) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec_Candidate = &__pyx_type_5_cdec_Candidate;
+ if (PyType_Ready(&__pyx_type_5_cdec_SufficientStats) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "SufficientStats", (PyObject *)&__pyx_type_5_cdec_SufficientStats) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec_SufficientStats = &__pyx_type_5_cdec_SufficientStats;
+ 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;}
+ __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;}
+ __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;}
+ __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;}
+ __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;}
__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_kbest) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_ptype_5_cdec___pyx_scope_struct_1_kbest = &__pyx_type_5_cdec___pyx_scope_struct_1_kbest;
- if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_2_kbest_tree) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_ptype_5_cdec___pyx_scope_struct_2_kbest_tree = &__pyx_type_5_cdec___pyx_scope_struct_2_kbest_tree;
- if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_3_sample) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_ptype_5_cdec___pyx_scope_struct_3_sample = &__pyx_type_5_cdec___pyx_scope_struct_3_sample;
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_1___iter__) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec___pyx_scope_struct_1___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_1___iter__;
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_2__phrase) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 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;}
+ __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;}
+ __pyx_ptype_5_cdec___pyx_scope_struct_5___str__ = &__pyx_type_5_cdec___pyx_scope_struct_5___str__;
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_6_genexpr) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec___pyx_scope_struct_6_genexpr = &__pyx_type_5_cdec___pyx_scope_struct_6_genexpr;
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_7___iter__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec___pyx_scope_struct_7___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_7___iter__;
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_8_kbest) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec___pyx_scope_struct_8_kbest = &__pyx_type_5_cdec___pyx_scope_struct_8_kbest;
+ 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;}
+ __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;}
+ __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;}
+ __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;}
+ __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;}
+ __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;}
+ __pyx_ptype_5_cdec___pyx_scope_struct_15___get__ = &__pyx_type_5_cdec___pyx_scope_struct_15___get__;
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_16___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec___pyx_scope_struct_16___get__ = &__pyx_type_5_cdec___pyx_scope_struct_16___get__;
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_17___iter__) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 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;}
+ __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;
/*--- Type import code ---*/
+ __pyx_ptype_4cdec_2sa_3_sa_Phrase = __Pyx_ImportType("cdec.sa._sa", "Phrase", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Phrase), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_vtabptr_4cdec_2sa_3_sa_Phrase = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_Phrase->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_4cdec_2sa_3_sa_Rule = __Pyx_ImportType("cdec.sa._sa", "Rule", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Rule), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Rule)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/*--- Variable import code ---*/
/*--- Function import code ---*/
+ __pyx_t_1 = __Pyx_ImportModule("cdec.sa._sa"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_ImportFunction(__pyx_t_1, "sym_tostring", (void (**)(void))&__pyx_f_4cdec_2sa_3_sa_sym_tostring, "char *(int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_ImportFunction(__pyx_t_1, "sym_tocat", (void (**)(void))&__pyx_f_4cdec_2sa_3_sa_sym_tocat, "char *(int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_ImportFunction(__pyx_t_1, "sym_isvar", (void (**)(void))&__pyx_f_4cdec_2sa_3_sa_sym_isvar, "int (int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_ImportFunction(__pyx_t_1, "sym_getindex", (void (**)(void))&__pyx_f_4cdec_2sa_3_sa_sym_getindex, "int (int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/*--- Execution code ---*/
- /* "_cdec.pyx":10
- * cimport kbest as kb
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":3
+ * cimport grammar
+ * cimport cdec.sa._sa as _sa
+ * import cdec.sa._sa as _sa # <<<<<<<<<<<<<<
+ *
+ * def _phrase(phrase):
+ */
+ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_INCREF(((PyObject *)__pyx_n_s_55));
+ PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s_55));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s_55));
+ __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s_54), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s___sa, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5
+ * import cdec.sa._sa as _sa
+ *
+ * def _phrase(phrase): # <<<<<<<<<<<<<<
+ * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase)
+ *
+ */
+ __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_5_cdec_1_phrase, NULL, __pyx_n_s___cdec); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s___phrase, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":190
+ * return []
+ *
+ * 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_GOTREF(__pyx_t_3);
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s__BLEU, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":191
+ *
+ * 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_GOTREF(__pyx_t_3);
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s__TER, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":192
+ * BLEU = Scorer('IBM_BLEU')
+ * TER = Scorer('TER')
+ * CER = Scorer('CER') # <<<<<<<<<<<<<<
+ */
+ __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_61), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s__CER, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+ /* "_cdec.pyx":22
+ * include "mteval.pxi"
*
* SetSilent(True) # <<<<<<<<<<<<<<
+ * decoder.register_feature_functions()
*
- * class ParseFailed(Exception):
*/
SetSilent(1);
- /* "_cdec.pyx":12
+ /* "_cdec.pyx":23
+ *
* SetSilent(True)
+ * decoder.register_feature_functions() # <<<<<<<<<<<<<<
+ *
+ * class InvalidConfig(Exception): pass
+ */
+ register_feature_functions();
+
+ /* "_cdec.pyx":25
+ * decoder.register_feature_functions()
*
- * class ParseFailed(Exception): # <<<<<<<<<<<<<<
- * pass
+ * class InvalidConfig(Exception): pass # <<<<<<<<<<<<<<
+ * class ParseFailed(Exception): pass
*
*/
- __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __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[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(__pyx_builtin_Exception);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_Exception);
__Pyx_GIVEREF(__pyx_builtin_Exception);
- __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s__ParseFailed, __pyx_n_s___cdec); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_4 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3), __pyx_n_s__InvalidConfig, __pyx_n_s___cdec); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ParseFailed, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s__InvalidConfig, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+
+ /* "_cdec.pyx":26
+ *
+ * class InvalidConfig(Exception): pass
+ * class ParseFailed(Exception): pass # <<<<<<<<<<<<<<
+ *
+ * def _make_config(config):
+ */
+ __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_INCREF(__pyx_builtin_Exception);
+ PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_builtin_Exception);
+ __Pyx_GIVEREF(__pyx_builtin_Exception);
+ __pyx_t_2 = __Pyx_CreateClass(((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_3), __pyx_n_s__ParseFailed, __pyx_n_s___cdec); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ParseFailed, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+
+ /* "_cdec.pyx":28
+ * class ParseFailed(Exception): pass
+ *
+ * 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_GOTREF(__pyx_t_3);
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s___make_config, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
/* "_cdec.pyx":1
* from libcpp.string cimport string # <<<<<<<<<<<<<<
* from libcpp.vector cimport vector
- * from cython.operator cimport dereference as deref
+ * from utils cimport *
+ */
+ __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+
+ /* "string.to_py":25
+ *
+ * @cname("__pyx_convert_string_to_py_")
+ * cdef object __pyx_convert_string_to_py_(string& s): # <<<<<<<<<<<<<<
+ * return s.data()[:s.size()]
+ *
*/
- __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(((PyObject *)__pyx_t_1));
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
if (__pyx_m) {
__Pyx_AddTraceback("init _cdec", __pyx_clineno, __pyx_lineno, __pyx_filename);
Py_DECREF(__pyx_m); __pyx_m = 0;
@@ -5177,141 +28417,6 @@ static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
return result;
}
-static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%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));
- #endif
-}
-
-static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- 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) {
- 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;
- }
- }
- }
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, **name);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%s() got an unexpected keyword argument '%s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
- const char *name, int exact)
-{
- if (!type) {
- PyErr_Format(PyExc_SystemError, "Missing type object");
- return 0;
- }
- if (none_allowed && obj == Py_None) return 1;
- else if (exact) {
- if (Py_TYPE(obj) == type) return 1;
- }
- else {
- if (PyObject_TypeCheck(obj, type)) return 1;
- }
- PyErr_Format(PyExc_TypeError,
- "Argument '%s' has incorrect type (expected %s, got %s)",
- name, type->tp_name, Py_TYPE(obj)->tp_name);
- return 0;
-}
-
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
PyObject *tmp_type, *tmp_value, *tmp_tb;
@@ -5465,15 +28570,240 @@ bad:
}
#endif
+static void __Pyx_RaiseArgtupleInvalid(
+ const char* func_name,
+ int exact,
+ Py_ssize_t num_min,
+ Py_ssize_t num_max,
+ Py_ssize_t num_found)
+{
+ Py_ssize_t num_expected;
+ const char *more_or_less;
+ if (num_found < num_min) {
+ num_expected = num_min;
+ more_or_less = "at least";
+ } else {
+ num_expected = num_max;
+ more_or_less = "at most";
+ }
+ if (exact) {
+ more_or_less = "exactly";
+ }
+ PyErr_Format(PyExc_TypeError,
+ "%s() takes %s %" PY_FORMAT_SIZE_T "d positional argument%s (%" PY_FORMAT_SIZE_T "d given)",
+ func_name, more_or_less, num_expected,
+ (num_expected == 1) ? "" : "s", num_found);
+}
+
+static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
+ PyObject *kwdict,
+ const char* function_name,
+ int kw_allowed)
+{
+ PyObject* key = 0;
+ Py_ssize_t pos = 0;
+#if CPYTHON_COMPILING_IN_PYPY
+ if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
+ goto invalid_keyword;
+ return 1;
+#else
+ while (PyDict_Next(kwdict, &pos, &key, 0)) {
+ #if PY_MAJOR_VERSION < 3
+ if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
+ #else
+ if (unlikely(!PyUnicode_Check(key)))
+ #endif
+ goto invalid_keyword_type;
+ }
+ if ((!kw_allowed) && unlikely(key))
+ goto invalid_keyword;
+ return 1;
+invalid_keyword_type:
+ PyErr_Format(PyExc_TypeError,
+ "%s() keywords must be strings", function_name);
+ return 0;
+#endif
+invalid_keyword:
+ PyErr_Format(PyExc_TypeError,
+ #if PY_MAJOR_VERSION < 3
+ "%s() got an unexpected keyword argument '%s'",
+ function_name, PyString_AsString(key));
+ #else
+ "%s() got an unexpected keyword argument '%U'",
+ function_name, key);
+ #endif
+ return 0;
+}
+
+static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
+ const char *name, int exact)
+{
+ if (!type) {
+ PyErr_Format(PyExc_SystemError, "Missing type object");
+ return 0;
+ }
+ if (none_allowed && obj == Py_None) return 1;
+ else if (exact) {
+ if (Py_TYPE(obj) == type) return 1;
+ }
+ else {
+ if (PyObject_TypeCheck(obj, type)) return 1;
+ }
+ PyErr_Format(PyExc_TypeError,
+ "Argument '%s' has incorrect type (expected %s, got %s)",
+ name, type->tp_name, Py_TYPE(obj)->tp_name);
+ return 0;
+}
+
+static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
+ if (unlikely(!type)) {
+ PyErr_Format(PyExc_SystemError, "Missing type object");
+ return 0;
+ }
+ if (likely(PyObject_TypeCheck(obj, type)))
+ return 1;
+ PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
+ Py_TYPE(obj)->tp_name, type->tp_name);
+ return 0;
+}
+
+static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
+ PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
+}
+
+static void __Pyx_RaiseDoubleKeywordsError(
+ const char* func_name,
+ PyObject* kw_name)
+{
+ PyErr_Format(PyExc_TypeError,
+ #if PY_MAJOR_VERSION >= 3
+ "%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));
+ #endif
+}
+
+static int __Pyx_ParseOptionalKeywords(
+ PyObject *kwds,
+ PyObject **argnames[],
+ PyObject *kwds2,
+ PyObject *values[],
+ Py_ssize_t num_pos_args,
+ const char* function_name)
+{
+ PyObject *key = 0, *value = 0;
+ Py_ssize_t pos = 0;
+ PyObject*** name;
+ PyObject*** first_kw_arg = argnames + num_pos_args;
+ while (PyDict_Next(kwds, &pos, &key, &value)) {
+ name = first_kw_arg;
+ 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) {
+ 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;
+ }
+ }
+ }
+ }
+ }
+ return 0;
+arg_passed_twice:
+ __Pyx_RaiseDoubleKeywordsError(function_name, **name);
+ goto bad;
+invalid_keyword_type:
+ PyErr_Format(PyExc_TypeError,
+ "%s() keywords must be strings", function_name);
+ goto bad;
+invalid_keyword:
+ PyErr_Format(PyExc_TypeError,
+ #if PY_MAJOR_VERSION < 3
+ "%s() got an unexpected keyword argument '%s'",
+ function_name, PyString_AsString(key));
+ #else
+ "%s() got an unexpected keyword argument '%U'",
+ function_name, key);
+ #endif
+bad:
+ return -1;
+}
+
+static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
+ PyErr_Format(PyExc_ValueError,
+ "too many values to unpack (expected %" PY_FORMAT_SIZE_T "d)", expected);
+}
+
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
PyErr_Format(PyExc_ValueError,
- "need more than %"PY_FORMAT_SIZE_T"d value%s to unpack",
+ "need more than %" PY_FORMAT_SIZE_T "d value%s to unpack",
index, (index == 1) ? "" : "s");
}
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
- PyErr_Format(PyExc_ValueError,
- "too many values to unpack (expected %"PY_FORMAT_SIZE_T"d)", expected);
+static CYTHON_INLINE int __Pyx_IterFinish(void) {
+#if CYTHON_COMPILING_IN_CPYTHON
+ PyThreadState *tstate = PyThreadState_GET();
+ PyObject* exc_type = tstate->curexc_type;
+ if (unlikely(exc_type)) {
+ if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
+ PyObject *exc_value, *exc_tb;
+ exc_value = tstate->curexc_value;
+ exc_tb = tstate->curexc_traceback;
+ tstate->curexc_type = 0;
+ tstate->curexc_value = 0;
+ tstate->curexc_traceback = 0;
+ Py_DECREF(exc_type);
+ Py_XDECREF(exc_value);
+ Py_XDECREF(exc_tb);
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+ return 0;
+#else
+ if (unlikely(PyErr_Occurred())) {
+ if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
+ PyErr_Clear();
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+ return 0;
+#endif
}
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
@@ -5481,19 +28811,54 @@ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
Py_DECREF(retval);
__Pyx_RaiseTooManyValuesError(expected);
return -1;
- } else if (PyErr_Occurred()) {
- if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
+ } else {
+ return __Pyx_IterFinish();
+ }
+ return 0;
+}
+
+static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
+ PyObject* next;
+ iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
+#if CYTHON_COMPILING_IN_CPYTHON
+ if (unlikely(!iternext)) {
+#else
+ if (unlikely(!iternext) || unlikely(!PyIter_Check(iterator))) {
+#endif
+ PyErr_Format(PyExc_TypeError,
+ "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
+ return NULL;
+ }
+ next = iternext(iterator);
+ if (likely(next))
+ return next;
+#if CYTHON_COMPILING_IN_CPYTHON
+#if PY_VERSION_HEX >= 0x03010000 || (PY_MAJOR_VERSION < 3 && PY_VERSION_HEX >= 0x02070000)
+ if (unlikely(iternext == &_PyObject_NextNotImplemented))
+ return NULL;
+#endif
+#endif
+ if (defval) {
+ PyObject* exc_type = PyErr_Occurred();
+ if (exc_type) {
+ if (unlikely(exc_type != PyExc_StopIteration) &&
+ !PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))
+ return NULL;
PyErr_Clear();
- return 0;
- } else {
- return -1;
}
+ Py_INCREF(defval);
+ return defval;
}
- return 0;
+ if (!PyErr_Occurred())
+ PyErr_SetNone(PyExc_StopIteration);
+ return NULL;
}
static double __Pyx__PyObject_AsDouble(PyObject* obj) {
PyObject* float_value;
+#if CYTHON_COMPILING_IN_PYPY
+ float_value = PyNumber_Float(obj);
+#else
if (Py_TYPE(obj)->tp_as_number && Py_TYPE(obj)->tp_as_number->nb_float) {
return PyFloat_AsDouble(obj);
} else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
@@ -5510,6 +28875,7 @@ static double __Pyx__PyObject_AsDouble(PyObject* obj) {
PyTuple_SET_ITEM(args, 0, 0);
Py_DECREF(args);
}
+#endif
if (likely(float_value)) {
double value = PyFloat_AS_DOUBLE(float_value);
Py_DECREF(float_value);
@@ -5521,6 +28887,7 @@ bad:
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
PyObject *local_type, *local_value, *local_tb;
+#if CYTHON_COMPILING_IN_CPYTHON
PyObject *tmp_type, *tmp_value, *tmp_tb;
PyThreadState *tstate = PyThreadState_GET();
local_type = tstate->curexc_type;
@@ -5529,19 +28896,27 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
tstate->curexc_type = 0;
tstate->curexc_value = 0;
tstate->curexc_traceback = 0;
+#else
+ PyErr_Fetch(&local_type, &local_value, &local_tb);
+#endif
PyErr_NormalizeException(&local_type, &local_value, &local_tb);
+#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(tstate->curexc_type))
+#else
+ if (unlikely(PyErr_Occurred()))
+#endif
goto bad;
#if PY_MAJOR_VERSION >= 3
if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
goto bad;
#endif
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
Py_INCREF(local_type);
Py_INCREF(local_value);
Py_INCREF(local_tb);
+ *type = local_type;
+ *value = local_value;
+ *tb = local_tb;
+#if CYTHON_COMPILING_IN_CPYTHON
tmp_type = tstate->exc_type;
tmp_value = tstate->exc_value;
tmp_tb = tstate->exc_traceback;
@@ -5549,10 +28924,13 @@ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
tstate->exc_value = local_value;
tstate->exc_traceback = local_tb;
/* Make sure tstate is in a consistent state when we XDECREF
- these objects (XDECREF may run arbitrary code). */
+ these objects (DECREF may run arbitrary code). */
Py_XDECREF(tmp_type);
Py_XDECREF(tmp_value);
Py_XDECREF(tmp_tb);
+#else
+ PyErr_SetExcInfo(local_type, local_value, local_tb);
+#endif
return 0;
bad:
*type = 0;
@@ -5564,19 +28942,8 @@ bad:
return -1;
}
-static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
- if (unlikely(!type)) {
- PyErr_Format(PyExc_SystemError, "Missing type object");
- return 0;
- }
- if (likely(PyObject_TypeCheck(obj, type)))
- return 1;
- PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
- Py_TYPE(obj)->tp_name, type->tp_name);
- return 0;
-}
-
static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
+#if CYTHON_COMPILING_IN_CPYTHON
PyThreadState *tstate = PyThreadState_GET();
*type = tstate->exc_type;
*value = tstate->exc_value;
@@ -5584,8 +28951,12 @@ static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value,
Py_XINCREF(*type);
Py_XINCREF(*value);
Py_XINCREF(*tb);
+#else
+ PyErr_GetExcInfo(type, value, tb);
+#endif
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
+#if CYTHON_COMPILING_IN_CPYTHON
PyObject *tmp_type, *tmp_value, *tmp_tb;
PyThreadState *tstate = PyThreadState_GET();
tmp_type = tstate->exc_type;
@@ -5597,11 +28968,82 @@ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb)
Py_XDECREF(tmp_type);
Py_XDECREF(tmp_value);
Py_XDECREF(tmp_tb);
+#else
+ PyErr_SetExcInfo(type, value, tb);
+#endif
+}
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
+ PyObject *py_import = 0;
+ PyObject *empty_list = 0;
+ PyObject *module = 0;
+ PyObject *global_dict = 0;
+ PyObject *empty_dict = 0;
+ PyObject *list;
+ py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
+ if (!py_import)
+ goto bad;
+ if (from_list)
+ list = from_list;
+ else {
+ empty_list = PyList_New(0);
+ if (!empty_list)
+ goto bad;
+ list = empty_list;
+ }
+ global_dict = PyModule_GetDict(__pyx_m);
+ if (!global_dict)
+ goto bad;
+ empty_dict = PyDict_New();
+ if (!empty_dict)
+ goto bad;
+ #if PY_VERSION_HEX >= 0x02050000
+ {
+ #if PY_MAJOR_VERSION >= 3
+ if (level == -1) {
+ if (strchr(__Pyx_MODULE_NAME, '.')) {
+ /* try package relative import first */
+ PyObject *py_level = PyInt_FromLong(1);
+ if (!py_level)
+ goto bad;
+ module = PyObject_CallFunctionObjArgs(py_import,
+ name, global_dict, empty_dict, list, py_level, NULL);
+ Py_DECREF(py_level);
+ if (!module) {
+ if (!PyErr_ExceptionMatches(PyExc_ImportError))
+ goto bad;
+ PyErr_Clear();
+ }
+ }
+ level = 0; /* try absolute import on failure */
+ }
+ #endif
+ if (!module) {
+ PyObject *py_level = PyInt_FromLong(level);
+ if (!py_level)
+ goto bad;
+ module = PyObject_CallFunctionObjArgs(py_import,
+ name, global_dict, empty_dict, list, py_level, NULL);
+ Py_DECREF(py_level);
+ }
+ }
+ #else
+ if (level>0) {
+ PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
+ goto bad;
+ }
+ module = PyObject_CallFunctionObjArgs(py_import,
+ name, global_dict, empty_dict, list, NULL);
+ #endif
+bad:
+ Py_XDECREF(empty_list);
+ Py_XDECREF(py_import);
+ Py_XDECREF(empty_dict);
+ return module;
}
static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
PyObject *metaclass;
- /* Default metaclass */
#if PY_MAJOR_VERSION < 3
if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
PyObject *base = PyTuple_GET_ITEM(bases, 0);
@@ -5631,7 +29073,6 @@ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *na
PyObject *metaclass;
if (PyDict_SetItemString(dict, "__module__", modname) < 0)
return NULL;
- /* Python2 __metaclass__ */
metaclass = PyDict_GetItemString(dict, "__metaclass__");
if (metaclass) {
Py_INCREF(metaclass);
@@ -5643,6 +29084,58 @@ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *na
return result;
}
+static CYTHON_INLINE WordID __Pyx_PyInt_from_py_WordID(PyObject* x) {
+ const WordID neg_one = (WordID)-1, const_zero = (WordID)0;
+ const int is_unsigned = const_zero < neg_one;
+ if (sizeof(WordID) == sizeof(char)) {
+ if (is_unsigned)
+ return (WordID)__Pyx_PyInt_AsUnsignedChar(x);
+ else
+ return (WordID)__Pyx_PyInt_AsSignedChar(x);
+ } else if (sizeof(WordID) == sizeof(short)) {
+ if (is_unsigned)
+ return (WordID)__Pyx_PyInt_AsUnsignedShort(x);
+ else
+ return (WordID)__Pyx_PyInt_AsSignedShort(x);
+ } else if (sizeof(WordID) == sizeof(int)) {
+ if (is_unsigned)
+ return (WordID)__Pyx_PyInt_AsUnsignedInt(x);
+ else
+ return (WordID)__Pyx_PyInt_AsSignedInt(x);
+ } else if (sizeof(WordID) == sizeof(long)) {
+ if (is_unsigned)
+ return (WordID)__Pyx_PyInt_AsUnsignedLong(x);
+ else
+ return (WordID)__Pyx_PyInt_AsSignedLong(x);
+ } else if (sizeof(WordID) == sizeof(PY_LONG_LONG)) {
+ if (is_unsigned)
+ return (WordID)__Pyx_PyInt_AsUnsignedLongLong(x);
+ else
+ return (WordID)__Pyx_PyInt_AsSignedLongLong(x);
+ } else {
+ WordID val;
+ PyObject *v = __Pyx_PyNumber_Int(x);
+ #if PY_VERSION_HEX < 0x03000000
+ if (likely(v) && !PyLong_Check(v)) {
+ PyObject *tmp = v;
+ v = PyNumber_Long(tmp);
+ Py_DECREF(tmp);
+ }
+ #endif
+ if (likely(v)) {
+ int one = 1; int is_little = (int)*(unsigned char *)&one;
+ unsigned char *bytes = (unsigned char *)&val;
+ int ret = _PyLong_AsByteArray((PyLongObject *)v,
+ bytes, sizeof(val),
+ is_little, !is_unsigned);
+ Py_DECREF(v);
+ if (likely(!ret))
+ return val;
+ }
+ return (WordID)-1;
+ }
+}
+
static PyObject* __Pyx_Globals() {
Py_ssize_t i;
/*PyObject *d;*/
@@ -5681,6 +29174,495 @@ bad:
return NULL;
}
+static PyObject *
+__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
+{
+ if (op->func_doc == NULL && op->func.m_ml->ml_doc) {
+#if PY_MAJOR_VERSION >= 3
+ op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
+#else
+ op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
+#endif
+ }
+ if (op->func_doc == 0) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+ Py_INCREF(op->func_doc);
+ return op->func_doc;
+}
+static int
+__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
+{
+ PyObject *tmp = op->func_doc;
+ if (value == NULL)
+ op->func_doc = Py_None; /* Mark as deleted */
+ else
+ op->func_doc = value;
+ Py_INCREF(op->func_doc);
+ Py_XDECREF(tmp);
+ return 0;
+}
+static PyObject *
+__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
+{
+ if (op->func_name == NULL) {
+#if PY_MAJOR_VERSION >= 3
+ op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
+#else
+ op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
+#endif
+ }
+ Py_INCREF(op->func_name);
+ return op->func_name;
+}
+static int
+__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
+{
+ PyObject *tmp;
+#if PY_MAJOR_VERSION >= 3
+ if (value == NULL || !PyUnicode_Check(value)) {
+#else
+ if (value == NULL || !PyString_Check(value)) {
+#endif
+ PyErr_SetString(PyExc_TypeError,
+ "__name__ must be set to a string object");
+ return -1;
+ }
+ tmp = op->func_name;
+ Py_INCREF(value);
+ op->func_name = value;
+ Py_XDECREF(tmp);
+ return 0;
+}
+static PyObject *
+__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
+{
+ PyObject *self;
+ self = m->func_closure;
+ if (self == NULL)
+ self = Py_None;
+ Py_INCREF(self);
+ return self;
+}
+static PyObject *
+__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
+{
+ if (op->func_dict == NULL) {
+ op->func_dict = PyDict_New();
+ if (op->func_dict == NULL)
+ return NULL;
+ }
+ Py_INCREF(op->func_dict);
+ return op->func_dict;
+}
+static int
+__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
+{
+ PyObject *tmp;
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError,
+ "function's dictionary may not be deleted");
+ return -1;
+ }
+ if (!PyDict_Check(value)) {
+ PyErr_SetString(PyExc_TypeError,
+ "setting function's dictionary to a non-dict");
+ return -1;
+ }
+ tmp = op->func_dict;
+ Py_INCREF(value);
+ op->func_dict = value;
+ Py_XDECREF(tmp);
+ return 0;
+}
+static PyObject *
+__Pyx_CyFunction_get_globals(CYTHON_UNUSED __pyx_CyFunctionObject *op)
+{
+ PyObject* dict = PyModule_GetDict(__pyx_m);
+ Py_XINCREF(dict);
+ return dict;
+}
+static PyObject *
+__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
+{
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+static PyObject *
+__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
+{
+ PyObject* result = (op->func_code) ? op->func_code : Py_None;
+ Py_INCREF(result);
+ return result;
+}
+static PyObject *
+__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op)
+{
+ if (op->defaults_tuple) {
+ Py_INCREF(op->defaults_tuple);
+ return op->defaults_tuple;
+ }
+ if (op->defaults_getter) {
+ PyObject *res = op->defaults_getter((PyObject *) op);
+ if (res) {
+ Py_INCREF(res);
+ op->defaults_tuple = res;
+ }
+ return res;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+static PyGetSetDef __pyx_CyFunction_getsets[] = {
+ {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
+ {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
+ {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
+ {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
+ {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
+ {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
+ {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
+ {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
+ {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
+ {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
+ {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
+ {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
+ {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
+ {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, 0, 0, 0},
+ {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, 0, 0, 0},
+ {0, 0, 0, 0, 0}
+};
+#ifndef PY_WRITE_RESTRICTED /* < Py2.5 */
+#define PY_WRITE_RESTRICTED WRITE_RESTRICTED
+#endif
+static PyMemberDef __pyx_CyFunction_members[] = {
+ {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
+ {0, 0, 0, 0, 0}
+};
+static PyObject *
+__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
+{
+#if PY_MAJOR_VERSION >= 3
+ return PyUnicode_FromString(m->func.m_ml->ml_name);
+#else
+ return PyString_FromString(m->func.m_ml->ml_name);
+#endif
+}
+static PyMethodDef __pyx_CyFunction_methods[] = {
+ {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
+ {0, 0, 0, 0}
+};
+static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags,
+ PyObject *closure, PyObject *module, PyObject* code) {
+ __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
+ if (op == NULL)
+ return NULL;
+ op->flags = flags;
+ op->func_weakreflist = NULL;
+ op->func.m_ml = ml;
+ op->func.m_self = (PyObject *) op;
+ Py_XINCREF(closure);
+ op->func_closure = closure;
+ Py_XINCREF(module);
+ op->func.m_module = module;
+ op->func_dict = NULL;
+ op->func_name = NULL;
+ op->func_doc = NULL;
+ op->func_classobj = NULL;
+ Py_XINCREF(code);
+ op->func_code = code;
+ op->defaults_pyobjects = 0;
+ op->defaults = NULL;
+ op->defaults_tuple = NULL;
+ op->defaults_getter = NULL;
+ PyObject_GC_Track(op);
+ return (PyObject *) op;
+}
+static int
+__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
+{
+ Py_CLEAR(m->func_closure);
+ Py_CLEAR(m->func.m_module);
+ Py_CLEAR(m->func_dict);
+ Py_CLEAR(m->func_name);
+ Py_CLEAR(m->func_doc);
+ Py_CLEAR(m->func_code);
+ Py_CLEAR(m->func_classobj);
+ Py_CLEAR(m->defaults_tuple);
+ if (m->defaults) {
+ PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
+ int i;
+ for (i = 0; i < m->defaults_pyobjects; i++)
+ Py_XDECREF(pydefaults[i]);
+ PyMem_Free(m->defaults);
+ m->defaults = NULL;
+ }
+ return 0;
+}
+static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
+{
+ PyObject_GC_UnTrack(m);
+ if (m->func_weakreflist != NULL)
+ PyObject_ClearWeakRefs((PyObject *) m);
+ __Pyx_CyFunction_clear(m);
+ PyObject_GC_Del(m);
+}
+static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
+{
+ Py_VISIT(m->func_closure);
+ Py_VISIT(m->func.m_module);
+ Py_VISIT(m->func_dict);
+ Py_VISIT(m->func_name);
+ Py_VISIT(m->func_doc);
+ Py_VISIT(m->func_code);
+ Py_VISIT(m->func_classobj);
+ Py_VISIT(m->defaults_tuple);
+ if (m->defaults) {
+ PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
+ int i;
+ for (i = 0; i < m->defaults_pyobjects; i++)
+ Py_VISIT(pydefaults[i]);
+ }
+ return 0;
+}
+static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
+{
+ __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
+ if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
+ Py_INCREF(func);
+ return func;
+ }
+ if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
+ if (type == NULL)
+ type = (PyObject *)(Py_TYPE(obj));
+ return PyMethod_New(func,
+ type, (PyObject *)(Py_TYPE(type)));
+ }
+ if (obj == Py_None)
+ obj = NULL;
+ return PyMethod_New(func, obj, type);
+}
+static PyObject*
+__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
+{
+ PyObject *func_name = __Pyx_CyFunction_get_name(op);
+#if PY_MAJOR_VERSION >= 3
+ return PyUnicode_FromFormat("<cyfunction %U at %p>",
+ func_name, (void *)op);
+#else
+ return PyString_FromFormat("<cyfunction %s at %p>",
+ PyString_AsString(func_name), (void *)op);
+#endif
+}
+#if CYTHON_COMPILING_IN_PYPY
+static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
+ PyCFunctionObject* f = (PyCFunctionObject*)func;
+ PyCFunction meth = PyCFunction_GET_FUNCTION(func);
+ PyObject *self = PyCFunction_GET_SELF(func);
+ Py_ssize_t size;
+ switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) {
+ case METH_VARARGS:
+ if (likely(kw == NULL) || PyDict_Size(kw) == 0)
+ return (*meth)(self, arg);
+ break;
+ case METH_VARARGS | METH_KEYWORDS:
+ return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
+ case METH_NOARGS:
+ if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
+ size = PyTuple_GET_SIZE(arg);
+ if (size == 0)
+ return (*meth)(self, NULL);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s() takes no arguments (%zd given)",
+ f->m_ml->ml_name, size);
+ return NULL;
+ }
+ break;
+ case METH_O:
+ if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
+ size = PyTuple_GET_SIZE(arg);
+ if (size == 1)
+ return (*meth)(self, PyTuple_GET_ITEM(arg, 0));
+ PyErr_Format(PyExc_TypeError,
+ "%.200s() takes exactly one argument (%zd given)",
+ f->m_ml->ml_name, size);
+ return NULL;
+ }
+ break;
+ default:
+ PyErr_SetString(PyExc_SystemError, "Bad call flags in "
+ "__Pyx_CyFunction_Call. METH_OLDARGS is no "
+ "longer supported!");
+ return NULL;
+ }
+ PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
+ f->m_ml->ml_name);
+ return NULL;
+}
+#else
+static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
+ return PyCFunction_Call(func, arg, kw);
+}
+#endif
+static PyTypeObject __pyx_CyFunctionType_type = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("cython_function_or_method"), /*tp_name*/
+ sizeof(__pyx_CyFunctionObject), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor) __Pyx_CyFunction_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+#if PY_MAJOR_VERSION < 3
+ 0, /*tp_compare*/
+#else
+ 0, /*reserved*/
+#endif
+ (reprfunc) __Pyx_CyFunction_repr, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ __Pyx_CyFunction_Call, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/
+ 0, /*tp_doc*/
+ (traverseproc) __Pyx_CyFunction_traverse, /*tp_traverse*/
+ (inquiry) __Pyx_CyFunction_clear, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ offsetof(__pyx_CyFunctionObject, func_weakreflist), /* tp_weaklistoffse */
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_CyFunction_methods, /*tp_methods*/
+ __pyx_CyFunction_members, /*tp_members*/
+ __pyx_CyFunction_getsets, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ __Pyx_CyFunction_descr_get, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/
+ 0, /*tp_init*/
+ 0, /*tp_alloc*/
+ 0, /*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 int __Pyx_CyFunction_init(void) {
+#if !CYTHON_COMPILING_IN_PYPY
+ __pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
+#endif
+ if (PyType_Ready(&__pyx_CyFunctionType_type) < 0)
+ return -1;
+ __pyx_CyFunctionType = &__pyx_CyFunctionType_type;
+ return 0;
+}
+static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
+ __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
+ m->defaults = PyMem_Malloc(size);
+ if (!m->defaults)
+ return PyErr_NoMemory();
+ memset(m->defaults, 0, sizeof(size));
+ m->defaults_pyobjects = pyobjects;
+ return m->defaults;
+}
+static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
+ __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
+ m->defaults_tuple = tuple;
+ Py_INCREF(tuple);
+}
+
+static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
+#if CYTHON_COMPILING_IN_PYPY
+ return PyObject_RichCompareBool(s1, s2, equals);
+#else
+ if (s1 == s2) {
+ return (equals == Py_EQ);
+ } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
+ 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;
@@ -6081,8 +30063,28 @@ 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
PyThreadState *tstate = PyThreadState_GET();
tmp_type = tstate->exc_type;
tmp_value = tstate->exc_value;
@@ -6090,6 +30092,10 @@ static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value,
tstate->exc_type = *type;
tstate->exc_value = *value;
tstate->exc_traceback = *tb;
+#else
+ PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
+ PyErr_SetExcInfo(*type, *value, *tb);
+#endif
*type = tmp_type;
*value = tmp_value;
*tb = tmp_tb;
@@ -6099,9 +30105,70 @@ static PyObject *__Pyx_Generator_Next(PyObject *self);
static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value);
static PyObject *__Pyx_Generator_Close(PyObject *self);
static PyObject *__Pyx_Generator_Throw(PyObject *gen, PyObject *args);
+static PyTypeObject *__pyx_GeneratorType = 0;
+#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
+#define __Pyx_Generator_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
+#if 1 || PY_VERSION_HEX < 0x030300B0
+static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) {
+ PyObject *et, *ev, *tb;
+ PyObject *value = NULL;
+ __Pyx_ErrFetch(&et, &ev, &tb);
+ if (!et) {
+ Py_XDECREF(tb);
+ Py_XDECREF(ev);
+ Py_INCREF(Py_None);
+ *pvalue = Py_None;
+ return 0;
+ }
+ if (unlikely(et != PyExc_StopIteration) &&
+ unlikely(!PyErr_GivenExceptionMatches(et, PyExc_StopIteration))) {
+ __Pyx_ErrRestore(et, ev, tb);
+ return -1;
+ }
+ if (likely(et == PyExc_StopIteration)) {
+ if (likely(!ev) || !PyObject_IsInstance(ev, PyExc_StopIteration)) {
+ if (!ev) {
+ Py_INCREF(Py_None);
+ ev = Py_None;
+ }
+ Py_XDECREF(tb);
+ Py_DECREF(et);
+ *pvalue = ev;
+ return 0;
+ }
+ }
+ PyErr_NormalizeException(&et, &ev, &tb);
+ if (unlikely(!PyObject_IsInstance(ev, PyExc_StopIteration))) {
+ __Pyx_ErrRestore(et, ev, tb);
+ return -1;
+ }
+ Py_XDECREF(tb);
+ Py_DECREF(et);
+#if PY_VERSION_HEX >= 0x030300A0
+ value = ((PyStopIterationObject *)ev)->value;
+ Py_INCREF(value);
+ Py_DECREF(ev);
+#else
+ {
+ PyObject* args = PyObject_GetAttrString(ev, "args");
+ Py_DECREF(ev);
+ if (likely(args)) {
+ value = PyObject_GetItem(args, 0);
+ Py_DECREF(args);
+ }
+ if (unlikely(!value)) {
+ __Pyx_ErrRestore(NULL, NULL, NULL);
+ Py_INCREF(Py_None);
+ value = Py_None;
+ }
+ }
+#endif
+ *pvalue = value;
+ return 0;
+}
+#endif
static CYTHON_INLINE
-void __Pyx_Generator_ExceptionClear(__pyx_GeneratorObject *self)
-{
+void __Pyx_Generator_ExceptionClear(__pyx_GeneratorObject *self) {
PyObject *exc_type = self->exc_type;
PyObject *exc_value = self->exc_value;
PyObject *exc_traceback = self->exc_traceback;
@@ -6113,14 +30180,18 @@ void __Pyx_Generator_ExceptionClear(__pyx_GeneratorObject *self)
Py_XDECREF(exc_traceback);
}
static CYTHON_INLINE
-PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value)
-{
- PyObject *retval;
- if (unlikely(self->is_running)) {
+int __Pyx_Generator_CheckRunning(__pyx_GeneratorObject *gen) {
+ if (unlikely(gen->is_running)) {
PyErr_SetString(PyExc_ValueError,
"generator already executing");
- return NULL;
+ return 1;
}
+ return 0;
+}
+static CYTHON_INLINE
+PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value) {
+ PyObject *retval;
+ assert(!self->is_running);
if (unlikely(self->resume_label == 0)) {
if (unlikely(value && value != Py_None)) {
PyErr_SetString(PyExc_TypeError,
@@ -6133,81 +30204,240 @@ PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value)
PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
- if (value)
- __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, &self->exc_traceback);
- else
+ if (value) {
+#if CYTHON_COMPILING_IN_PYPY
+#else
+ /* Generators always return to their most recent caller, not
+ * necessarily their creator. */
+ if (self->exc_traceback) {
+ PyThreadState *tstate = PyThreadState_GET();
+ PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
+ PyFrameObject *f = tb->tb_frame;
+ Py_XINCREF(tstate->frame);
+ assert(f->f_back == NULL);
+ f->f_back = tstate->frame;
+ }
+#endif
+ __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
+ &self->exc_traceback);
+ } else {
__Pyx_Generator_ExceptionClear(self);
+ }
self->is_running = 1;
retval = self->body((PyObject *) self, value);
self->is_running = 0;
- if (retval)
- __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, &self->exc_traceback);
- else
+ if (retval) {
+ __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
+ &self->exc_traceback);
+#if CYTHON_COMPILING_IN_PYPY
+#else
+ /* Don't keep the reference to f_back any longer than necessary. It
+ * may keep a chain of frames alive or it could create a reference
+ * cycle. */
+ if (self->exc_traceback) {
+ PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
+ PyFrameObject *f = tb->tb_frame;
+ Py_CLEAR(f->f_back);
+ }
+#endif
+ } else {
__Pyx_Generator_ExceptionClear(self);
+ }
return retval;
}
-static PyObject *__Pyx_Generator_Next(PyObject *self)
-{
- return __Pyx_Generator_SendEx((__pyx_GeneratorObject *) self, Py_None);
+static CYTHON_INLINE
+PyObject *__Pyx_Generator_FinishDelegation(__pyx_GeneratorObject *gen) {
+ PyObject *ret;
+ PyObject *val = NULL;
+ __Pyx_Generator_Undelegate(gen);
+ __Pyx_PyGen_FetchStopIterationValue(&val);
+ ret = __Pyx_Generator_SendEx(gen, val);
+ Py_XDECREF(val);
+ return ret;
}
-static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value)
-{
- return __Pyx_Generator_SendEx((__pyx_GeneratorObject *) self, value);
+static PyObject *__Pyx_Generator_Next(PyObject *self) {
+ __pyx_GeneratorObject *gen = (__pyx_GeneratorObject*) self;
+ PyObject *yf = gen->yieldfrom;
+ if (unlikely(__Pyx_Generator_CheckRunning(gen)))
+ return NULL;
+ if (yf) {
+ PyObject *ret;
+ gen->is_running = 1;
+ ret = Py_TYPE(yf)->tp_iternext(yf);
+ gen->is_running = 0;
+ if (likely(ret)) {
+ return ret;
+ }
+ return __Pyx_Generator_FinishDelegation(gen);
+ }
+ return __Pyx_Generator_SendEx(gen, Py_None);
}
-static PyObject *__Pyx_Generator_Close(PyObject *self)
-{
- __pyx_GeneratorObject *generator = (__pyx_GeneratorObject *) self;
- PyObject *retval;
+static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value) {
+ __pyx_GeneratorObject *gen = (__pyx_GeneratorObject*) self;
+ PyObject *yf = gen->yieldfrom;
+ if (unlikely(__Pyx_Generator_CheckRunning(gen)))
+ return NULL;
+ if (yf) {
+ PyObject *ret;
+ gen->is_running = 1;
+ if (__Pyx_Generator_CheckExact(yf)) {
+ ret = __Pyx_Generator_Send(yf, value);
+ } else {
+ if (value == Py_None)
+ ret = PyIter_Next(yf);
+ else
+ ret = PyObject_CallMethod(yf, (char*)"send", (char*)"O", value);
+ }
+ gen->is_running = 0;
+ if (likely(ret)) {
+ return ret;
+ }
+ return __Pyx_Generator_FinishDelegation(gen);
+ }
+ return __Pyx_Generator_SendEx(gen, value);
+}
+static int __Pyx_Generator_CloseIter(__pyx_GeneratorObject *gen, PyObject *yf) {
+ PyObject *retval = NULL;
+ int err = 0;
+ if (__Pyx_Generator_CheckExact(yf)) {
+ retval = __Pyx_Generator_Close(yf);
+ if (!retval)
+ return -1;
+ } else {
+ PyObject *meth;
+ gen->is_running = 1;
+ meth = PyObject_GetAttrString(yf, "close");
+ if (unlikely(!meth)) {
+ if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_WriteUnraisable(yf);
+ }
+ PyErr_Clear();
+ } else {
+ retval = PyObject_CallFunction(meth, NULL);
+ Py_DECREF(meth);
+ if (!retval)
+ err = -1;
+ }
+ gen->is_running = 0;
+ }
+ Py_XDECREF(retval);
+ return err;
+}
+static PyObject *__Pyx_Generator_Close(PyObject *self) {
+ __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
+ PyObject *retval, *raised_exception;
+ PyObject *yf = gen->yieldfrom;
+ int err = 0;
+ if (unlikely(__Pyx_Generator_CheckRunning(gen)))
+ return NULL;
+ if (yf) {
+ Py_INCREF(yf);
+ err = __Pyx_Generator_CloseIter(gen, yf);
+ __Pyx_Generator_Undelegate(gen);
+ Py_DECREF(yf);
+ }
+ if (err == 0)
#if PY_VERSION_HEX < 0x02050000
- PyErr_SetNone(PyExc_StopIteration);
+ PyErr_SetNone(PyExc_StopIteration);
#else
- PyErr_SetNone(PyExc_GeneratorExit);
+ PyErr_SetNone(PyExc_GeneratorExit);
#endif
- retval = __Pyx_Generator_SendEx(generator, NULL);
+ retval = __Pyx_Generator_SendEx(gen, NULL);
if (retval) {
Py_DECREF(retval);
PyErr_SetString(PyExc_RuntimeError,
"generator ignored GeneratorExit");
return NULL;
}
-#if PY_VERSION_HEX < 0x02050000
- if (PyErr_ExceptionMatches(PyExc_StopIteration))
-#else
- if (PyErr_ExceptionMatches(PyExc_StopIteration)
- || PyErr_ExceptionMatches(PyExc_GeneratorExit))
+ raised_exception = PyErr_Occurred();
+ if (!raised_exception
+ || raised_exception == PyExc_StopIteration
+#if PY_VERSION_HEX >= 0x02050000
+ || raised_exception == PyExc_GeneratorExit
+ || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit)
#endif
+ || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration))
{
- PyErr_Clear(); /* ignore these errors */
+ if (raised_exception) PyErr_Clear(); /* ignore these errors */
Py_INCREF(Py_None);
return Py_None;
}
return NULL;
}
-static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args)
-{
- __pyx_GeneratorObject *generator = (__pyx_GeneratorObject *) self;
+static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) {
+ __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
PyObject *typ;
PyObject *tb = NULL;
PyObject *val = NULL;
+ PyObject *yf = gen->yieldfrom;
if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
return NULL;
+ if (unlikely(__Pyx_Generator_CheckRunning(gen)))
+ return NULL;
+ if (yf) {
+ PyObject *ret;
+ Py_INCREF(yf);
+#if PY_VERSION_HEX >= 0x02050000
+ if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) {
+ int err = __Pyx_Generator_CloseIter(gen, yf);
+ Py_DECREF(yf);
+ __Pyx_Generator_Undelegate(gen);
+ if (err < 0)
+ return __Pyx_Generator_SendEx(gen, NULL);
+ goto throw_here;
+ }
+#endif
+ gen->is_running = 1;
+ if (__Pyx_Generator_CheckExact(yf)) {
+ ret = __Pyx_Generator_Throw(yf, args);
+ } else {
+ PyObject *meth = PyObject_GetAttrString(yf, "throw");
+ if (unlikely(!meth)) {
+ Py_DECREF(yf);
+ if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ gen->is_running = 0;
+ return NULL;
+ }
+ PyErr_Clear();
+ __Pyx_Generator_Undelegate(gen);
+ gen->is_running = 0;
+ goto throw_here;
+ }
+ ret = PyObject_CallObject(meth, args);
+ Py_DECREF(meth);
+ }
+ gen->is_running = 0;
+ Py_DECREF(yf);
+ if (!ret) {
+ ret = __Pyx_Generator_FinishDelegation(gen);
+ }
+ return ret;
+ }
+throw_here:
__Pyx_Raise(typ, val, tb, NULL);
- return __Pyx_Generator_SendEx(generator, NULL);
+ return __Pyx_Generator_SendEx(gen, NULL);
}
-static int
-__Pyx_Generator_traverse(PyObject *self, visitproc visit, void *arg)
-{
+static int __Pyx_Generator_traverse(PyObject *self, visitproc visit, void *arg) {
__pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
Py_VISIT(gen->closure);
Py_VISIT(gen->classobj);
+ Py_VISIT(gen->yieldfrom);
Py_VISIT(gen->exc_type);
Py_VISIT(gen->exc_value);
Py_VISIT(gen->exc_traceback);
return 0;
}
-static void
-__Pyx_Generator_dealloc(PyObject *self)
-{
+static int __Pyx_Generator_clear(PyObject *self) {
+ __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
+ Py_CLEAR(gen->closure);
+ Py_CLEAR(gen->classobj);
+ Py_CLEAR(gen->yieldfrom);
+ Py_CLEAR(gen->exc_type);
+ Py_CLEAR(gen->exc_value);
+ Py_CLEAR(gen->exc_traceback);
+ return 0;
+}
+static void __Pyx_Generator_dealloc(PyObject *self) {
__pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
PyObject_GC_UnTrack(gen);
if (gen->gi_weakreflist != NULL)
@@ -6219,16 +30449,10 @@ __Pyx_Generator_dealloc(PyObject *self)
return; /* resurrected. :( */
}
PyObject_GC_UnTrack(self);
- Py_CLEAR(gen->closure);
- Py_CLEAR(gen->classobj);
- Py_CLEAR(gen->exc_type);
- Py_CLEAR(gen->exc_value);
- Py_CLEAR(gen->exc_traceback);
+ __Pyx_Generator_clear(self);
PyObject_GC_Del(gen);
}
-static void
-__Pyx_Generator_del(PyObject *self)
-{
+static void __Pyx_Generator_del(PyObject *self) {
PyObject *res;
PyObject *error_type, *error_value, *error_traceback;
__pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
@@ -6257,11 +30481,13 @@ __Pyx_Generator_del(PyObject *self)
_Py_NewReference(self);
self->ob_refcnt = refcnt;
}
+#if CYTHON_COMPILING_FOR_CPYTHON
assert(PyType_IS_GC(self->ob_type) &&
_Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
/* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
* we need to undo that. */
_Py_DEC_REFTOTAL;
+#endif
/* If Py_TRACE_REFS, _Py_NewReference re-added self to the object
* chain, so no more to do there.
* If COUNT_ALLOCS, the original decref bumped tp_frees, and
@@ -6269,13 +30495,17 @@ __Pyx_Generator_del(PyObject *self)
* undone.
*/
#ifdef COUNT_ALLOCS
- --self->ob_type->tp_frees;
- --self->ob_type->tp_allocs;
+ --Py_TYPE(self)->tp_frees;
+ --Py_TYPE(self)->tp_allocs;
#endif
}
static PyMemberDef __pyx_Generator_memberlist[] = {
{(char *) "gi_running",
+#if PY_VERSION_HEX >= 0x02060000
+ T_BOOL,
+#else
T_INT,
+#endif
offsetof(__pyx_GeneratorObject, is_running),
READONLY,
NULL},
@@ -6287,7 +30517,7 @@ static PyMethodDef __pyx_Generator_methods[] = {
{__Pyx_NAMESTR("close"), (PyCFunction) __Pyx_Generator_Close, METH_NOARGS, 0},
{0, 0, 0, 0}
};
-static PyTypeObject __pyx_GeneratorType = {
+static PyTypeObject __pyx_GeneratorType_type = {
PyVarObject_HEAD_INIT(0, 0)
__Pyx_NAMESTR("generator"), /*tp_name*/
sizeof(__pyx_GeneratorObject), /*tp_basicsize*/
@@ -6308,7 +30538,7 @@ static PyTypeObject __pyx_GeneratorType = {
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
- PyObject_GenericGetAttr, /*tp_getattro*/
+ 0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/
@@ -6317,7 +30547,7 @@ static PyTypeObject __pyx_GeneratorType = {
0, /*tp_clear*/
0, /*tp_richcompare*/
offsetof(__pyx_GeneratorObject, gi_weakreflist), /* tp_weaklistoffse */
- PyObject_SelfIter, /*tp_iter*/
+ 0, /*tp_iter*/
(iternextfunc) __Pyx_Generator_Next, /*tp_iternext*/
__pyx_Generator_methods, /*tp_methods*/
__pyx_Generator_memberlist, /*tp_members*/
@@ -6342,12 +30572,10 @@ static PyTypeObject __pyx_GeneratorType = {
0, /*tp_version_tag*/
#endif
};
-static
-__pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
- PyObject *closure)
-{
+static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
+ PyObject *closure) {
__pyx_GeneratorObject *gen =
- PyObject_GC_New(__pyx_GeneratorObject, &__pyx_GeneratorType);
+ PyObject_GC_New(__pyx_GeneratorObject, &__pyx_GeneratorType_type);
if (gen == NULL)
return NULL;
gen->body = body;
@@ -6356,6 +30584,7 @@ __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
gen->is_running = 0;
gen->resume_label = 0;
gen->classobj = NULL;
+ gen->yieldfrom = NULL;
gen->exc_type = NULL;
gen->exc_value = NULL;
gen->exc_traceback = NULL;
@@ -6363,9 +30592,14 @@ __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
PyObject_GC_Track(gen);
return gen;
}
-static int __pyx_Generator_init(void)
-{
- return PyType_Ready(&__pyx_GeneratorType);
+static int __pyx_Generator_init(void) {
+ __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr;
+ __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
+ if (PyType_Ready(&__pyx_GeneratorType_type)) {
+ return -1;
+ }
+ __pyx_GeneratorType = &__pyx_GeneratorType_type;
+ return 0;
}
static int __Pyx_check_binary_version(void) {
@@ -6387,6 +30621,164 @@ static int __Pyx_check_binary_version(void) {
return 0;
}
+static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
+#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
+ PyObject *ob = PyCapsule_New(vtable, 0, 0);
+#else
+ PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
+#endif
+ if (!ob)
+ goto bad;
+ if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
+ goto bad;
+ Py_DECREF(ob);
+ return 0;
+bad:
+ Py_XDECREF(ob);
+ return -1;
+}
+
+#ifndef __PYX_HAVE_RT_ImportType
+#define __PYX_HAVE_RT_ImportType
+static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
+ size_t size, int strict)
+{
+ PyObject *py_module = 0;
+ PyObject *result = 0;
+ PyObject *py_name = 0;
+ char warning[200];
+ py_module = __Pyx_ImportModule(module_name);
+ if (!py_module)
+ goto bad;
+ py_name = __Pyx_PyIdentifier_FromString(class_name);
+ if (!py_name)
+ goto bad;
+ result = PyObject_GetAttr(py_module, py_name);
+ Py_DECREF(py_name);
+ py_name = 0;
+ Py_DECREF(py_module);
+ py_module = 0;
+ if (!result)
+ goto bad;
+ if (!PyType_Check(result)) {
+ PyErr_Format(PyExc_TypeError,
+ "%s.%s is not a type object",
+ module_name, class_name);
+ goto bad;
+ }
+ if (!strict && (size_t)((PyTypeObject *)result)->tp_basicsize > size) {
+ PyOS_snprintf(warning, sizeof(warning),
+ "%s.%s size changed, may indicate binary incompatibility",
+ module_name, class_name);
+ #if PY_VERSION_HEX < 0x02050000
+ if (PyErr_Warn(NULL, warning) < 0) goto bad;
+ #else
+ if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
+ #endif
+ }
+ else if ((size_t)((PyTypeObject *)result)->tp_basicsize != size) {
+ PyErr_Format(PyExc_ValueError,
+ "%s.%s has the wrong size, try recompiling",
+ module_name, class_name);
+ goto bad;
+ }
+ return (PyTypeObject *)result;
+bad:
+ Py_XDECREF(py_module);
+ Py_XDECREF(result);
+ return NULL;
+}
+#endif
+
+#ifndef __PYX_HAVE_RT_ImportModule
+#define __PYX_HAVE_RT_ImportModule
+static PyObject *__Pyx_ImportModule(const char *name) {
+ PyObject *py_name = 0;
+ PyObject *py_module = 0;
+ py_name = __Pyx_PyIdentifier_FromString(name);
+ if (!py_name)
+ goto bad;
+ py_module = PyImport_Import(py_name);
+ Py_DECREF(py_name);
+ return py_module;
+bad:
+ Py_XDECREF(py_name);
+ return 0;
+}
+#endif
+
+static void* __Pyx_GetVtable(PyObject *dict) {
+ void* ptr;
+ PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
+ if (!ob)
+ goto bad;
+#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
+ ptr = PyCapsule_GetPointer(ob, 0);
+#else
+ ptr = PyCObject_AsVoidPtr(ob);
+#endif
+ if (!ptr && !PyErr_Occurred())
+ PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
+ Py_DECREF(ob);
+ return ptr;
+bad:
+ Py_XDECREF(ob);
+ return NULL;
+}
+
+#ifndef __PYX_HAVE_RT_ImportFunction
+#define __PYX_HAVE_RT_ImportFunction
+static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
+ PyObject *d = 0;
+ PyObject *cobj = 0;
+ union {
+ void (*fp)(void);
+ void *p;
+ } tmp;
+ d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
+ if (!d)
+ goto bad;
+ cobj = PyDict_GetItemString(d, funcname);
+ if (!cobj) {
+ PyErr_Format(PyExc_ImportError,
+ "%s does not export expected C function %s",
+ PyModule_GetName(module), funcname);
+ goto bad;
+ }
+#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
+ if (!PyCapsule_IsValid(cobj, sig)) {
+ PyErr_Format(PyExc_TypeError,
+ "C function %s.%s has wrong signature (expected %s, got %s)",
+ PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
+ goto bad;
+ }
+ tmp.p = PyCapsule_GetPointer(cobj, sig);
+#else
+ {const char *desc, *s1, *s2;
+ desc = (const char *)PyCObject_GetDesc(cobj);
+ if (!desc)
+ goto bad;
+ s1 = desc; s2 = sig;
+ while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
+ if (*s1 != *s2) {
+ PyErr_Format(PyExc_TypeError,
+ "C function %s.%s has wrong signature (expected %s, got %s)",
+ PyModule_GetName(module), funcname, sig, desc);
+ goto bad;
+ }
+ tmp.p = PyCObject_AsVoidPtr(cobj);}
+#endif
+ *f = tmp.fp;
+ if (!(*f))
+ goto bad;
+ Py_DECREF(d);
+ return 0;
+bad:
+ Py_XDECREF(d);
+ return -1;
+}
+#endif
+
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
int start = 0, mid = 0, end = count - 1;
if (end >= 0 && code_line > entries[end].code_line) {