summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2012-07-06 11:45:32 +0200
committerPatrick Simianer <p@simianer.de>2012-07-06 11:45:32 +0200
commit902591f9cc48a3b4cfc0a8d5df07898827bddf71 (patch)
tree17f023a7dd5ee0f527acf9d6a5388b6d96094d13
parent96bb9719858dd1600d70a3affee42d0e0c5cd862 (diff)
parentf6bd206d83d8e71227e42c933f56c2ccd43fe013 (diff)
Merge remote-tracking branch 'upstream/master'
-rw-r--r--dtrain/score.cc8
-rw-r--r--python/src/_cdec.cpp3174
-rw-r--r--python/src/_cdec.pyx18
-rw-r--r--python/src/lattice.pxi12
-rw-r--r--python/src/mteval.pxi21
-rw-r--r--python/src/vectors.pxi6
6 files changed, 2642 insertions, 597 deletions
diff --git a/dtrain/score.cc b/dtrain/score.cc
index 4a7cac6e..34fc86a9 100644
--- a/dtrain/score.cc
+++ b/dtrain/score.cc
@@ -103,7 +103,7 @@ SmoothBleuScorer::Score(vector<WordID>& hyp, vector<WordID>& ref,
i_bleu[j] += (1/((score_t)j+1)) * i_ng;
}
}
- sum += exp(i_bleu[i])/(pow(2.0, N_-i));
+ sum += exp(i_bleu[i])/pow(2.0, (double)(N_-i));
}
return brevity_penalty(hyp_len, ref_len) * sum;
}
@@ -126,7 +126,7 @@ SumBleuScorer::Score(vector<WordID>& hyp, vector<WordID>& ref,
unsigned j = 1;
for (unsigned i = 0; i < M; i++) {
if (counts.sum_[i] == 0 || counts.clipped_[i] == 0) break;
- sum += ((score_t)counts.clipped_[i]/counts.sum_[i])/pow(2., N_-j+1);
+ sum += ((score_t)counts.clipped_[i]/counts.sum_[i])/pow(2.0, (double) (N_-j+1));
j++;
}
return brevity_penalty(hyp_len, ref_len) * sum;
@@ -150,7 +150,7 @@ SumExpBleuScorer::Score(vector<WordID>& hyp, vector<WordID>& ref,
unsigned j = 1;
for (unsigned i = 0; i < M; i++) {
if (counts.sum_[i] == 0 || counts.clipped_[i] == 0) break;
- sum += exp(((score_t)counts.clipped_[i]/counts.sum_[i]))/pow(2., N_-j+1);
+ sum += exp(((score_t)counts.clipped_[i]/counts.sum_[i]))/pow(2.0, (double) (N_-j+1));
j++;
}
return brevity_penalty(hyp_len, ref_len) * sum;
@@ -178,7 +178,7 @@ SumWhateverBleuScorer::Score(vector<WordID>& hyp, vector<WordID>& ref,
unsigned j = 1;
for (unsigned i = 0; i < M; i++) {
if (counts.sum_[i] == 0 || counts.clipped_[i] == 0) break;
- sum += exp(v[i] * log(((score_t)counts.clipped_[i]/counts.sum_[i])))/pow(2., N_-j+1);
+ sum += exp(v[i] * log(((score_t)counts.clipped_[i]/counts.sum_[i])))/pow(2.0, (double) (N_-j+1));
j++;
}
return brevity_penalty(hyp_len, ref_len) * sum;
diff --git a/python/src/_cdec.cpp b/python/src/_cdec.cpp
index bc522b32..3a127ba9 100644
--- a/python/src/_cdec.cpp
+++ b/python/src/_cdec.cpp
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.16 on Mon Jul 2 17:01:11 2012 */
+/* Generated by Cython 0.16 on Thu Jul 5 16:20:15 2012 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -402,11 +402,13 @@ struct __pyx_obj_5_cdec_Lattice;
struct __pyx_obj_5_cdec___pyx_scope_struct____iter__;
struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest;
struct __pyx_obj_5_cdec_Candidate;
+struct __pyx_obj_5_cdec___pyx_scope_struct_8_lines;
struct __pyx_obj_5_cdec___pyx_scope_struct_5_sample;
struct __pyx_obj_5_cdec_DenseVector;
struct __pyx_obj_5_cdec___pyx_scope_struct_6___iter__;
-struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__;
-struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__;
+struct __pyx_obj_5_cdec___pyx_scope_struct_9___iter__;
+struct __pyx_obj_5_cdec___pyx_scope_struct_10___iter__;
+struct __pyx_obj_5_cdec___pyx_scope_struct_7_todot;
struct __pyx_opt_args_5_cdec_as_str;
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":3
@@ -421,7 +423,7 @@ struct __pyx_opt_args_5_cdec_as_str {
PyObject *error_msg;
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":109
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":122
* return CandidateSet(self)
*
* cdef class Scorer: # <<<<<<<<<<<<<<
@@ -434,7 +436,7 @@ struct __pyx_obj_5_cdec_Scorer {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":59
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":70
* return result
*
* cdef class CandidateSet: # <<<<<<<<<<<<<<
@@ -449,7 +451,7 @@ struct __pyx_obj_5_cdec_CandidateSet {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":27
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":36
* return fmap
*
* cdef class SufficientStats: # <<<<<<<<<<<<<<
@@ -525,7 +527,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_3_kbest_tree {
*
* cdef class Decoder: # <<<<<<<<<<<<<<
* cdef decoder.Decoder* dec
- * cdef public DenseVector weights
+ * cdef DenseVector weights
*/
struct __pyx_obj_5_cdec_Decoder {
PyObject_HEAD
@@ -534,7 +536,7 @@ struct __pyx_obj_5_cdec_Decoder {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":90
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":103
* self.cs.AddKBestCandidates(hypergraph.hg[0], k, self.scorer.get())
*
* cdef class SegmentEvaluator: # <<<<<<<<<<<<<<
@@ -624,8 +626,8 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_2_kbest {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":13
- * return ret
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":22
+ * return stats
*
* cdef class Candidate: # <<<<<<<<<<<<<<
* cdef mteval.Candidate* candidate
@@ -638,6 +640,29 @@ struct __pyx_obj_5_cdec_Candidate {
};
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":59
+ *
+ * def todot(self):
+ * def lines(): # <<<<<<<<<<<<<<
+ * yield 'digraph lattice {'
+ * yield 'rankdir = LR;'
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_8_lines {
+ PyObject_HEAD
+ struct __pyx_obj_5_cdec___pyx_scope_struct_7_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/hypergraph.pxi":75
* del derivations
*
@@ -686,14 +711,31 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_6___iter__ {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":82
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":54
+ * return self.stats.size()
+ *
+ * def __iter__(self): # <<<<<<<<<<<<<<
+ * for i in range(len(self)):
+ * yield self.stats[0][i]
+ */
+struct __pyx_obj_5_cdec___pyx_scope_struct_9___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":95
* return candidate
*
* def __iter__(self): # <<<<<<<<<<<<<<
* cdef unsigned i
* for i in range(len(self)):
*/
-struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__ {
+struct __pyx_obj_5_cdec___pyx_scope_struct_10___iter__ {
PyObject_HEAD
unsigned int __pyx_v_i;
struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self;
@@ -702,20 +744,16 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__ {
};
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":45
- * return self.stats.size()
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":58
+ * del self.lattice
*
- * def __iter__(self): # <<<<<<<<<<<<<<
- * for i in range(len(self)):
- * yield self.stats[0][i]
+ * def todot(self): # <<<<<<<<<<<<<<
+ * def lines():
+ * yield 'digraph lattice {'
*/
-struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ {
+struct __pyx_obj_5_cdec___pyx_scope_struct_7_todot {
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 *);
+ struct __pyx_obj_5_cdec_Lattice *__pyx_v_self;
};
#ifndef CYTHON_REFNANNY
@@ -878,6 +916,8 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i)
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}
+static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);
+
static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */
#define __Pyx_PyObject_AsDouble(obj) \
((likely(PyFloat_CheckExact(obj))) ? \
@@ -895,6 +935,48 @@ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *na
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);
+
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
@@ -1011,9 +1093,12 @@ static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_3_kbest_tree = 0;
static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_4_kbest_features = 0;
static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_5_sample = 0;
static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_6___iter__ = 0;
-static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_7___iter__ = 0;
-static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_8___iter__ = 0;
+static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_7_todot = 0;
+static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_8_lines = 0;
+static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_9___iter__ = 0;
+static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_10___iter__ = 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_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject *, PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "_cdec"
int __pyx_module_is_main__cdec = 0;
@@ -1042,17 +1127,18 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_11dot(struct __pyx_obj_5_cdec_Sp
static PyObject *__pyx_pf_5_cdec_12SparseVector_13__richcmp__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y, int __pyx_v_op); /* proto */
static Py_ssize_t __pyx_pf_5_cdec_12SparseVector_15__len__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
static int __pyx_pf_5_cdec_12SparseVector_17__contains__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, char *__pyx_v_fname); /* proto */
-static PyObject *__pyx_pf_5_cdec_12SparseVector_19__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_21__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_23__imul__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_19__neg__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_21__iadd__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_23__isub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_25__imul__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar); /* proto */
#if PY_MAJOR_VERSION < 3
-static PyObject *__pyx_pf_5_cdec_12SparseVector_25__idiv__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_27__idiv__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar); /* proto */
#endif
-static PyObject *__pyx_pf_5_cdec_12SparseVector_27__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_29__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_31__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_29__add__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_31__sub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_33__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
#if PY_MAJOR_VERSION < 3
-static PyObject *__pyx_pf_5_cdec_12SparseVector_33__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
+static PyObject *__pyx_pf_5_cdec_12SparseVector_35__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
#endif
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 */
@@ -1074,6 +1160,8 @@ static Py_ssize_t __pyx_pf_5_cdec_7Lattice_6__len__(struct __pyx_obj_5_cdec_Latt
static PyObject *__pyx_pf_5_cdec_7Lattice_8__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5_cdec_7Lattice_10__iter__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
static void __pyx_pf_5_cdec_7Lattice_13__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */
+static 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 */
@@ -1084,11 +1172,11 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_6detail___get__(struct __pyx_
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__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_9__add__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_x, struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_y); /* proto */
+static PyObject *__pyx_pf_5_cdec_15SufficientStats_9__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, unsigned int __pyx_v_k); /* 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 */
@@ -1100,19 +1188,31 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
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_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_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_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 char __pyx_k_1[] = "cannot take the dot product of %s and SparseVector";
static char __pyx_k_2[] = "comparison not implemented for SparseVector";
static char __pyx_k_10[] = "csplit_preserve_full_word";
static char __pyx_k_11[] = "cannot reweight hypergraph with %s";
static char __pyx_k_13[] = "Cannot create lattice from %s";
static char __pyx_k_14[] = "lattice index out of range";
-static char __pyx_k_19[] = "Cannot convert type %s to str";
-static char __pyx_k_23[] = "Cannot translate input type %s";
+static char __pyx_k_19[] = "digraph lattice {";
+ static char __pyx_k_20[] = "rankdir = LR;";
+ static char __pyx_k_21[] = "node [shape=circle];";
+ static char __pyx_k_22[] = "%d -> %d [label=\"%s\"];";
+ static char __pyx_k_23[] = "\"";
+ static char __pyx_k_24[] = "\\\"";
+ static char __pyx_k_26[] = "%d [shape=doublecircle]";
+static char __pyx_k_27[] = "}";
+static char __pyx_k_30[] = "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi";
+static char __pyx_k_31[] = "\n";
+static char __pyx_k_33[] = "Cannot convert type %s to str";
+static char __pyx_k_35[] = "candidate set index out of range";
+static char __pyx_k_37[] = "cannot initialize weights with %s";
+static char __pyx_k_40[] = "Cannot translate input type %s";
+static char __pyx_k__i[] = "i";
static char __pyx_k__k[] = "k";
static char __pyx_k__TER[] = "TER";
static char __pyx_k__dot[] = "dot";
@@ -1120,20 +1220,27 @@ static char __pyx_k__inp[] = "inp";
static char __pyx_k__plf[] = "plf";
static char __pyx_k__BLEU[] = "BLEU";
static char __pyx_k__eval[] = "eval";
+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__self[] = "self";
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__split[] = "split";
static char __pyx_k__strip[] = "strip";
static char __pyx_k__config[] = "config";
static char __pyx_k__decode[] = "decode";
static char __pyx_k__encode[] = "encode";
+static char __pyx_k__weight[] = "weight";
static char __pyx_k__density[] = "density";
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__";
@@ -1158,7 +1265,19 @@ static PyObject *__pyx_kp_s_13;
static PyObject *__pyx_kp_s_14;
static PyObject *__pyx_kp_s_19;
static PyObject *__pyx_kp_s_2;
+static PyObject *__pyx_kp_s_20;
+static PyObject *__pyx_kp_s_21;
+static PyObject *__pyx_kp_s_22;
static PyObject *__pyx_kp_s_23;
+static PyObject *__pyx_kp_s_24;
+static PyObject *__pyx_kp_s_26;
+static PyObject *__pyx_kp_s_27;
+static PyObject *__pyx_kp_s_30;
+static PyObject *__pyx_kp_s_31;
+static PyObject *__pyx_kp_s_33;
+static PyObject *__pyx_kp_s_35;
+static PyObject *__pyx_kp_s_37;
+static PyObject *__pyx_kp_s_40;
static PyObject *__pyx_n_s__BLEU;
static PyObject *__pyx_n_s__Exception;
static PyObject *__pyx_n_s__IBM_BLEU;
@@ -1176,6 +1295,7 @@ static PyObject *__pyx_n_s___cdec;
static PyObject *__pyx_n_s__beam_alpha;
static PyObject *__pyx_n_s__config;
static PyObject *__pyx_n_s__decode;
+static PyObject *__pyx_n_s__delta;
static PyObject *__pyx_n_s__density;
static PyObject *__pyx_n_s__dot;
static PyObject *__pyx_n_s__encode;
@@ -1185,18 +1305,25 @@ static PyObject *__pyx_n_s__eval;
static PyObject *__pyx_n_s__evaluator;
static PyObject *__pyx_n_s__grammar;
static PyObject *__pyx_n_s__hypergraph;
+static PyObject *__pyx_n_s__i;
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__label;
+static PyObject *__pyx_n_s__lines;
static PyObject *__pyx_n_s__name;
static PyObject *__pyx_n_s__open;
static PyObject *__pyx_n_s__plf;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__refs;
+static PyObject *__pyx_n_s__replace;
static PyObject *__pyx_n_s__self;
static PyObject *__pyx_n_s__sentence;
static PyObject *__pyx_n_s__split;
static PyObject *__pyx_n_s__strip;
static PyObject *__pyx_n_s__utf8;
+static PyObject *__pyx_n_s__weight;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_k_tuple_3;
@@ -1211,11 +1338,16 @@ static PyObject *__pyx_k_tuple_15;
static PyObject *__pyx_k_tuple_16;
static PyObject *__pyx_k_tuple_17;
static PyObject *__pyx_k_tuple_18;
-static PyObject *__pyx_k_tuple_20;
-static PyObject *__pyx_k_tuple_21;
-static PyObject *__pyx_k_tuple_22;
-static PyObject *__pyx_k_tuple_24;
static PyObject *__pyx_k_tuple_25;
+static PyObject *__pyx_k_tuple_28;
+static PyObject *__pyx_k_tuple_32;
+static PyObject *__pyx_k_tuple_34;
+static PyObject *__pyx_k_tuple_36;
+static PyObject *__pyx_k_tuple_38;
+static PyObject *__pyx_k_tuple_39;
+static PyObject *__pyx_k_tuple_41;
+static PyObject *__pyx_k_tuple_42;
+static PyObject *__pyx_k_codeobj_29;
/* Python wrapper */
static Py_ssize_t __pyx_pw_5_cdec_11DenseVector_1__len__(PyObject *__pyx_v_self); /*proto*/
@@ -2599,7 +2731,7 @@ static int __pyx_pf_5_cdec_12SparseVector_17__contains__(struct __pyx_obj_5_cdec
* def __contains__(self, char* fname):
* return self.vector.nonzero(FDConvert(fname)) # <<<<<<<<<<<<<<
*
- * def __iadd__(SparseVector self, SparseVector other):
+ * def __neg__(self):
*/
__pyx_r = __pyx_v_self->vector->nonzero(FD::Convert(__pyx_v_fname));
goto __pyx_L0;
@@ -2611,13 +2743,97 @@ static int __pyx_pf_5_cdec_12SparseVector_17__contains__(struct __pyx_obj_5_cdec
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_20__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_20__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_20__neg__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_20__neg__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__neg__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_19__neg__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self));
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":84
+ * return self.vector.nonzero(FDConvert(fname))
+ *
+ * def __neg__(self): # <<<<<<<<<<<<<<
+ * cdef SparseVector result = SparseVector()
+ * result.vector = new FastSparseVector[weight_t](self.vector[0])
+ */
+
+static PyObject *__pyx_pf_5_cdec_12SparseVector_19__neg__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) {
+ 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":85
+ *
+ * def __neg__(self):
+ * cdef SparseVector result = SparseVector() # <<<<<<<<<<<<<<
+ * result.vector = new FastSparseVector[weight_t](self.vector[0])
+ * result.vector[0] *= -1.0
+ */
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
+ __pyx_t_1 = 0;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":86
+ * def __neg__(self):
+ * cdef SparseVector result = 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":87
+ * cdef SparseVector result = 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":88
+ * 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_22__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_22__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
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 = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_19__iadd__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other));
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_21__iadd__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other));
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
@@ -2626,20 +2842,20 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_20__iadd__(PyObject *__pyx_v_sel
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":84
- * return self.vector.nonzero(FDConvert(fname))
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":90
+ * return result
*
* def __iadd__(SparseVector self, SparseVector other): # <<<<<<<<<<<<<<
* self.vector[0] += other.vector[0]
* return self
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_19__iadd__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_21__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":85
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":91
*
* def __iadd__(SparseVector self, SparseVector other):
* self.vector[0] += other.vector[0] # <<<<<<<<<<<<<<
@@ -2648,7 +2864,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_19__iadd__(struct __pyx_obj_5_cd
*/
(__pyx_v_self->vector[0]) += (__pyx_v_other->vector[0]);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":86
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":92
* def __iadd__(SparseVector self, SparseVector other):
* self.vector[0] += other.vector[0]
* return self # <<<<<<<<<<<<<<
@@ -2668,13 +2884,13 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_19__iadd__(struct __pyx_obj_5_cd
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_22__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_22__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_24__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_24__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
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 = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_21__isub__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other));
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_23__isub__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other));
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
@@ -2683,7 +2899,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_22__isub__(PyObject *__pyx_v_sel
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":88
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":94
* return self
*
* def __isub__(SparseVector self, SparseVector other): # <<<<<<<<<<<<<<
@@ -2691,12 +2907,12 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_22__isub__(PyObject *__pyx_v_sel
* return self
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_21__isub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_23__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":89
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":95
*
* def __isub__(SparseVector self, SparseVector other):
* self.vector[0] -= other.vector[0] # <<<<<<<<<<<<<<
@@ -2705,7 +2921,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_21__isub__(struct __pyx_obj_5_cd
*/
(__pyx_v_self->vector[0]) -= (__pyx_v_other->vector[0]);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":90
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":96
* def __isub__(SparseVector self, SparseVector other):
* self.vector[0] -= other.vector[0]
* return self # <<<<<<<<<<<<<<
@@ -2725,14 +2941,14 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_21__isub__(struct __pyx_obj_5_cd
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_24__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_24__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_26__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_26__imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar) {
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 = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_scalar = __pyx_PyFloat_AsFloat(__pyx_arg_scalar); if (unlikely((__pyx_v_scalar == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
@@ -2740,12 +2956,12 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_24__imul__(PyObject *__pyx_v_sel
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_23__imul__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((float)__pyx_v_scalar));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_25__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":92
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":98
* return self
*
* def __imul__(SparseVector self, float scalar): # <<<<<<<<<<<<<<
@@ -2753,12 +2969,12 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_24__imul__(PyObject *__pyx_v_sel
* return self
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_23__imul__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_25__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":93
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":99
*
* def __imul__(SparseVector self, float scalar):
* self.vector[0] *= scalar # <<<<<<<<<<<<<<
@@ -2767,7 +2983,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_23__imul__(struct __pyx_obj_5_cd
*/
(__pyx_v_self->vector[0]) *= __pyx_v_scalar;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":94
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":100
* def __imul__(SparseVector self, float scalar):
* self.vector[0] *= scalar
* return self # <<<<<<<<<<<<<<
@@ -2788,14 +3004,14 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_23__imul__(struct __pyx_obj_5_cd
/* Python wrapper */
#if PY_MAJOR_VERSION < 3
-static PyObject *__pyx_pw_5_cdec_12SparseVector_26__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_26__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_28__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_28__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_scalar) {
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 = 96; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_scalar = __pyx_PyFloat_AsFloat(__pyx_arg_scalar); if (unlikely((__pyx_v_scalar == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
@@ -2803,13 +3019,13 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_26__idiv__(PyObject *__pyx_v_sel
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_25__idiv__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((float)__pyx_v_scalar));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_27__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":96
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":102
* return self
*
* def __idiv__(SparseVector self, float scalar): # <<<<<<<<<<<<<<
@@ -2818,12 +3034,12 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_26__idiv__(PyObject *__pyx_v_sel
*/
#if PY_MAJOR_VERSION < 3
-static PyObject *__pyx_pf_5_cdec_12SparseVector_25__idiv__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, float __pyx_v_scalar) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_27__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":97
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":103
*
* def __idiv__(SparseVector self, float scalar):
* self.vector[0] /= scalar # <<<<<<<<<<<<<<
@@ -2832,7 +3048,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_25__idiv__(struct __pyx_obj_5_cd
*/
(__pyx_v_self->vector[0]) /= __pyx_v_scalar;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":98
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":104
* def __idiv__(SparseVector self, float scalar):
* self.vector[0] /= scalar
* return self # <<<<<<<<<<<<<<
@@ -2853,14 +3069,14 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_25__idiv__(struct __pyx_obj_5_cd
#endif /*!(#if PY_MAJOR_VERSION < 3)*/
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_28__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_28__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_30__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_30__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
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 = 100; __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 = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_27__add__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y));
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 106; __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 = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_29__add__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y));
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
@@ -2869,7 +3085,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_28__add__(PyObject *__pyx_v_x, P
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":100
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":106
* return self
*
* def __add__(SparseVector x, SparseVector y): # <<<<<<<<<<<<<<
@@ -2877,7 +3093,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_28__add__(PyObject *__pyx_v_x, P
* result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0])
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_27__add__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_29__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
@@ -2887,19 +3103,19 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_27__add__(struct __pyx_obj_5_cde
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__add__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":101
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":107
*
* def __add__(SparseVector x, SparseVector y):
* cdef SparseVector result = SparseVector() # <<<<<<<<<<<<<<
* result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0])
* return result
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":102
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":108
* def __add__(SparseVector x, SparseVector y):
* cdef SparseVector result = SparseVector()
* result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0]) # <<<<<<<<<<<<<<
@@ -2908,7 +3124,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_27__add__(struct __pyx_obj_5_cde
*/
__pyx_v_result->vector = new FastSparseVector<weight_t>(((__pyx_v_x->vector[0]) + (__pyx_v_y->vector[0])));
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":103
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":109
* cdef SparseVector result = SparseVector()
* result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0])
* return result # <<<<<<<<<<<<<<
@@ -2934,14 +3150,14 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_27__add__(struct __pyx_obj_5_cde
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_30__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_30__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_32__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_32__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
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 = 105; __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 = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_29__sub__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y));
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 111; __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 = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_31__sub__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y));
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
@@ -2950,7 +3166,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_30__sub__(PyObject *__pyx_v_x, P
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":105
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":111
* return result
*
* def __sub__(SparseVector x, SparseVector y): # <<<<<<<<<<<<<<
@@ -2958,7 +3174,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_30__sub__(PyObject *__pyx_v_x, P
* result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0])
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_29__sub__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_x, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_y) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_31__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
@@ -2968,19 +3184,19 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_29__sub__(struct __pyx_obj_5_cde
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__sub__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":106
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":112
*
* def __sub__(SparseVector x, SparseVector y):
* cdef SparseVector result = SparseVector() # <<<<<<<<<<<<<<
* result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0])
* return result
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":107
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":113
* def __sub__(SparseVector x, SparseVector y):
* cdef SparseVector result = SparseVector()
* result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0]) # <<<<<<<<<<<<<<
@@ -2989,7 +3205,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_29__sub__(struct __pyx_obj_5_cde
*/
__pyx_v_result->vector = new FastSparseVector<weight_t>(((__pyx_v_x->vector[0]) - (__pyx_v_y->vector[0])));
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":108
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":114
* cdef SparseVector result = SparseVector()
* result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0])
* return result # <<<<<<<<<<<<<<
@@ -3015,17 +3231,17 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_29__sub__(struct __pyx_obj_5_cde
}
/* Python wrapper */
-static PyObject *__pyx_pw_5_cdec_12SparseVector_32__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_32__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_34__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_34__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__mul__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_31__mul__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_33__mul__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":110
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":116
* return result
*
* def __mul__(x, y): # <<<<<<<<<<<<<<
@@ -3033,7 +3249,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_32__mul__(PyObject *__pyx_v_x, P
* cdef float scalar
*/
-static PyObject *__pyx_pf_5_cdec_12SparseVector_31__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_33__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;
@@ -3047,7 +3263,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_31__mul__(PyObject *__pyx_v_x, P
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__mul__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":113
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":119
* cdef SparseVector vector
* cdef float scalar
* if isinstance(x, SparseVector): vector, scalar = x, y # <<<<<<<<<<<<<<
@@ -3059,10 +3275,10 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_31__mul__(PyObject *__pyx_v_x, P
__pyx_t_2 = __Pyx_TypeCheck(__pyx_v_x, __pyx_t_1);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_2) {
- if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 119; __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 = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_y); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 119; __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;
@@ -3070,36 +3286,36 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_31__mul__(PyObject *__pyx_v_x, P
}
/*else*/ {
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":114
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":120
* cdef float scalar
* if isinstance(x, SparseVector): vector, scalar = x, y
* else: vector, scalar = y, x # <<<<<<<<<<<<<<
* cdef SparseVector result = 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 = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(((__pyx_v_y) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_y, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __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 = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_x); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __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":115
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":121
* if isinstance(x, SparseVector): vector, scalar = x, y
* else: vector, scalar = y, x
* cdef SparseVector result = SparseVector() # <<<<<<<<<<<<<<
* result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar)
* return result
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":116
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":122
* else: vector, scalar = y, x
* cdef SparseVector result = SparseVector()
* result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar) # <<<<<<<<<<<<<<
@@ -3108,7 +3324,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_31__mul__(PyObject *__pyx_v_x, P
*/
__pyx_v_result->vector = new FastSparseVector<weight_t>(((__pyx_v_vector->vector[0]) * __pyx_v_scalar));
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":117
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":123
* cdef SparseVector result = SparseVector()
* result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar)
* return result # <<<<<<<<<<<<<<
@@ -3136,18 +3352,18 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_31__mul__(PyObject *__pyx_v_x, P
/* Python wrapper */
#if PY_MAJOR_VERSION < 3
-static PyObject *__pyx_pw_5_cdec_12SparseVector_34__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
-static PyObject *__pyx_pw_5_cdec_12SparseVector_34__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+static PyObject *__pyx_pw_5_cdec_12SparseVector_36__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
+static PyObject *__pyx_pw_5_cdec_12SparseVector_36__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__div__ (wrapper)", 0);
- __pyx_r = __pyx_pf_5_cdec_12SparseVector_33__div__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));
+ __pyx_r = __pyx_pf_5_cdec_12SparseVector_35__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":119
+/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":125
* return result
*
* def __div__(x, y): # <<<<<<<<<<<<<<
@@ -3156,7 +3372,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_34__div__(PyObject *__pyx_v_x, P
*/
#if PY_MAJOR_VERSION < 3
-static PyObject *__pyx_pf_5_cdec_12SparseVector_33__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
+static PyObject *__pyx_pf_5_cdec_12SparseVector_35__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;
@@ -3170,7 +3386,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_33__div__(PyObject *__pyx_v_x, P
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__div__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":122
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":128
* cdef SparseVector vector
* cdef float scalar
* if isinstance(x, SparseVector): vector, scalar = x, y # <<<<<<<<<<<<<<
@@ -3182,10 +3398,10 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_33__div__(PyObject *__pyx_v_x, P
__pyx_t_2 = __Pyx_TypeCheck(__pyx_v_x, __pyx_t_1);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_2) {
- if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 128; __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 = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_y); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 128; __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;
@@ -3193,36 +3409,36 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_33__div__(PyObject *__pyx_v_x, P
}
/*else*/ {
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":123
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":129
* cdef float scalar
* if isinstance(x, SparseVector): vector, scalar = x, y
* else: vector, scalar = y, x # <<<<<<<<<<<<<<
* cdef SparseVector result = 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 = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(((__pyx_v_y) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_y, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 129; __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 = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_x); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 129; __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":124
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":130
* if isinstance(x, SparseVector): vector, scalar = x, y
* else: vector, scalar = y, x
* cdef SparseVector result = SparseVector() # <<<<<<<<<<<<<<
* result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar)
* return result
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":125
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":131
* else: vector, scalar = y, x
* cdef SparseVector result = SparseVector()
* result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar) # <<<<<<<<<<<<<<
@@ -3230,7 +3446,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_33__div__(PyObject *__pyx_v_x, P
*/
__pyx_v_result->vector = new FastSparseVector<weight_t>(((__pyx_v_vector->vector[0]) / __pyx_v_scalar));
- /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":126
+ /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":132
* cdef SparseVector result = SparseVector()
* result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar)
* return result # <<<<<<<<<<<<<<
@@ -5919,6 +6135,7 @@ static void __pyx_pw_5_cdec_7Lattice_14__dealloc__(PyObject *__pyx_v_self) {
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
* del self.lattice
+ *
*/
static void __pyx_pf_5_cdec_7Lattice_13__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
@@ -5929,12 +6146,527 @@ static void __pyx_pf_5_cdec_7Lattice_13__dealloc__(CYTHON_UNUSED struct __pyx_ob
*
* def __dealloc__(self):
* del self.lattice # <<<<<<<<<<<<<<
+ *
+ * def todot(self):
*/
delete __pyx_v_self->lattice;
__Pyx_RefNannyFinishContext();
}
+/* Python wrapper */
+static PyObject *__pyx_pw_5_cdec_7Lattice_16todot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5_cdec_7Lattice_16todot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+ PyObject *__pyx_r = 0;
+ __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_2generator9(__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_self = __pyx_self;
+ __pyx_r = __pyx_pf_5_cdec_7Lattice_5todot_lines(__pyx_self);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":59
+ *
+ * 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_8_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_8_lines *)__pyx_ptype_5_cdec___pyx_scope_struct_8_lines->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_8_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_7_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_2generator9, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 59; __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_2generator9(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+ struct __pyx_obj_5_cdec___pyx_scope_struct_8_lines *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_8_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[3]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":60
+ * def todot(self):
+ * def lines():
+ * yield 'digraph lattice {' # <<<<<<<<<<<<<<
+ * yield 'rankdir = LR;'
+ * yield 'node [shape=circle];'
+ */
+ __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
+ __pyx_r = ((PyObject *)__pyx_kp_s_19);
+ __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[3]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":61
+ * def lines():
+ * yield 'digraph lattice {'
+ * yield 'rankdir = LR;' # <<<<<<<<<<<<<<
+ * yield 'node [shape=circle];'
+ * for i in range(len(self)):
+ */
+ __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
+ __pyx_r = ((PyObject *)__pyx_kp_s_20);
+ __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[3]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":62
+ * 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_21));
+ __pyx_r = ((PyObject *)__pyx_kp_s_21);
+ __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[3]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":63
+ * 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[3]; __pyx_lineno = 63; __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[3]; __pyx_lineno = 63; __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[3]; __pyx_lineno = 63; __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[3]; __pyx_lineno = 63; __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[3]; __pyx_lineno = 63; __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[3]; __pyx_lineno = 63; __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;
+ __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
+ } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) {
+ if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+ __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
+ } 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[3]; __pyx_lineno = 63; __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":64
+ * 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[3]; __pyx_lineno = 64; __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[3]; __pyx_lineno = 64; __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;
+ __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++;
+ } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_5)) {
+ if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
+ __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++;
+ } 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[3]; __pyx_lineno = 64; __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 (likely(PyTuple_CheckExact(sequence))) {
+ if (unlikely(PyTuple_GET_SIZE(sequence) != 3)) {
+ if (PyTuple_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
+ else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
+ {__pyx_filename = __pyx_f[3]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0);
+ __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1);
+ __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2);
+ } else {
+ if (unlikely(PyList_GET_SIZE(sequence) != 3)) {
+ if (PyList_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
+ else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
+ {__pyx_filename = __pyx_f[3]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ __pyx_t_8 = PyList_GET_ITEM(sequence, 0);
+ __pyx_t_9 = PyList_GET_ITEM(sequence, 1);
+ __pyx_t_10 = PyList_GET_ITEM(sequence, 2);
+ }
+ __Pyx_INCREF(__pyx_t_8);
+ __Pyx_INCREF(__pyx_t_9);
+ __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[3]; __pyx_lineno = 64; __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[3]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+ goto __pyx_L12_unpacking_done;
+ __pyx_L11_unpacking_failed:;
+ __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+ if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
+ if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[3]; __pyx_lineno = 64; __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":65
+ * 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[3]; __pyx_lineno = 65; __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[3]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_10);
+ __pyx_t_9 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 65; __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[3]; __pyx_lineno = 65; __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_22), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 65; __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[3]; __pyx_lineno = 65; __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":66
+ * 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[3]; __pyx_lineno = 66; __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[3]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_26), __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 66; __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[3]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":67
+ * 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_27));
+ __pyx_r = ((PyObject *)__pyx_kp_s_27);
+ __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[3]; __pyx_lineno = 67; __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_RefNannyFinishContext();
+ return NULL;
+}
+
+/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":58
+ * del self.lattice
+ *
+ * def todot(self): # <<<<<<<<<<<<<<
+ * def lines():
+ * yield 'digraph lattice {'
+ */
+
+static PyObject *__pyx_pf_5_cdec_7Lattice_15todot(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_7_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_7_todot *)__pyx_ptype_5_cdec___pyx_scope_struct_7_todot->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_7_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":59
+ *
+ * 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_29)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 59; __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":68
+ * 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_31), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 68; __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[3]; __pyx_lineno = 68; __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[3]; __pyx_lineno = 68; __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[3]; __pyx_lineno = 68; __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[3]; __pyx_lineno = 68; __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_32), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 68; __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
*
@@ -5944,7 +6676,7 @@ static void __pyx_pf_5_cdec_7Lattice_13__dealloc__(CYTHON_UNUSED struct __pyx_ob
*/
static char *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_sentence, struct __pyx_opt_args_5_cdec_as_str *__pyx_optional_args) {
- PyObject *__pyx_v_error_msg = ((PyObject *)__pyx_kp_s_19);
+ PyObject *__pyx_v_error_msg = ((PyObject *)__pyx_kp_s_33);
PyObject *__pyx_v_ret = 0;
char *__pyx_r;
__Pyx_RefNannyDeclarations
@@ -5984,7 +6716,7 @@ static char *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_sentence, struct __pyx_opt_
*/
__pyx_t_1 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_20), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_34), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 6; __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[4]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -6048,7 +6780,7 @@ static char *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_sentence, struct __pyx_opt_
* raise TypeError(error_msg % type(sentence))
* return ret # <<<<<<<<<<<<<<
*
- * cdef class Candidate:
+ * cdef SufficientStats as_stats(x, y):
*/
__pyx_t_4 = PyBytes_AsString(((PyObject *)__pyx_v_ret)); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = __pyx_t_4;
@@ -6067,6 +6799,135 @@ static char *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_sentence, struct __pyx_opt_
return __pyx_r;
}
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":13
+ * return ret
+ *
+ * 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":14
+ *
+ * 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":15
+ * 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[4]; __pyx_lineno = 15; __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":16
+ * 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[4]; __pyx_lineno = 16; __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[4]; __pyx_lineno = 16; __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":17
+ * 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[4]; __pyx_lineno = 17; __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":18
+ * 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":19
+ * 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":20
+ * 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) {
@@ -6078,7 +6939,7 @@ static PyObject *__pyx_pw_5_cdec_9Candidate_5words_1__get__(PyObject *__pyx_v_se
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":18
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":27
*
* property words:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -6097,7 +6958,7 @@ static PyObject *__pyx_pf_5_cdec_9Candidate_5words___get__(struct __pyx_obj_5_cd
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":19
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":28
* property words:
* def __get__(self):
* return unicode(GetString(self.candidate.ewords).c_str(), encoding='utf8') # <<<<<<<<<<<<<<
@@ -6105,17 +6966,17 @@ static PyObject *__pyx_pf_5_cdec_9Candidate_5words___get__(struct __pyx_obj_5_cd
* 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[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_FromString(TD::GetString(__pyx_v_self->candidate->ewords).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 28; __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[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 28; __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[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 28; __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[4]; __pyx_lineno = 19; __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[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 28; __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[4]; __pyx_lineno = 28; __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;
@@ -6148,7 +7009,7 @@ static PyObject *__pyx_pw_5_cdec_9Candidate_4fmap_1__get__(PyObject *__pyx_v_sel
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":22
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":31
*
* property fmap:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -6166,19 +7027,19 @@ static PyObject *__pyx_pf_5_cdec_9Candidate_4fmap___get__(struct __pyx_obj_5_cde
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":23
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":32
* property fmap:
* def __get__(self):
* cdef SparseVector fmap = SparseVector() # <<<<<<<<<<<<<<
* fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap)
* return fmap
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SparseVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_fmap = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":24
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":33
* def __get__(self):
* cdef SparseVector fmap = SparseVector()
* fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap) # <<<<<<<<<<<<<<
@@ -6187,7 +7048,7 @@ static PyObject *__pyx_pf_5_cdec_9Candidate_4fmap___get__(struct __pyx_obj_5_cde
*/
__pyx_v_fmap->vector = new FastSparseVector<weight_t>(__pyx_v_self->candidate->fmap);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":25
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":34
* cdef SparseVector fmap = SparseVector()
* fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap)
* return fmap # <<<<<<<<<<<<<<
@@ -6223,7 +7084,7 @@ static PyObject *__pyx_pw_5_cdec_9Candidate_5score_1__get__(PyObject *__pyx_v_se
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":15
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":24
* cdef class Candidate:
* cdef mteval.Candidate* candidate
* cdef public float score # <<<<<<<<<<<<<<
@@ -6240,7 +7101,7 @@ static PyObject *__pyx_pf_5_cdec_9Candidate_5score___get__(struct __pyx_obj_5_cd
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[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->score); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -6277,7 +7138,7 @@ static int __pyx_pf_5_cdec_9Candidate_5score_2__set__(struct __pyx_obj_5_cdec_Ca
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[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __pyx_PyFloat_AsFloat(__pyx_v_value); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_self->score = __pyx_t_1;
__pyx_r = 0;
@@ -6299,7 +7160,7 @@ static void __pyx_pw_5_cdec_15SufficientStats_1__dealloc__(PyObject *__pyx_v_sel
__Pyx_RefNannyFinishContext();
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":31
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":40
* cdef mteval.EvaluationMetric* metric
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
@@ -6311,7 +7172,7 @@ static void __pyx_pf_5_cdec_15SufficientStats___dealloc__(CYTHON_UNUSED struct _
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":32
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":41
*
* def __dealloc__(self):
* del self.stats # <<<<<<<<<<<<<<
@@ -6334,7 +7195,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_5score_1__get__(PyObject *__p
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":35
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":44
*
* property score:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -6351,7 +7212,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_5score___get__(struct __pyx_o
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":36
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":45
* property score:
* def __get__(self):
* return self.metric.ComputeScore(self.stats[0]) # <<<<<<<<<<<<<<
@@ -6359,7 +7220,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_5score___get__(struct __pyx_o
* 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[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->metric->ComputeScore((__pyx_v_self->stats[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -6388,7 +7249,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_6detail_1__get__(PyObject *__
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":39
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":48
*
* property detail:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -6405,7 +7266,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_6detail___get__(struct __pyx_
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":40
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":49
* property detail:
* def __get__(self):
* return self.metric.DetailedScore(self.stats[0]).c_str() # <<<<<<<<<<<<<<
@@ -6413,7 +7274,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_6detail___get__(struct __pyx_
* 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[4]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __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[4]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
__pyx_r = ((PyObject *)__pyx_t_1);
__pyx_t_1 = 0;
@@ -6442,7 +7303,7 @@ static Py_ssize_t __pyx_pw_5_cdec_15SufficientStats_3__len__(PyObject *__pyx_v_s
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":42
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":51
* return self.metric.DetailedScore(self.stats[0]).c_str()
*
* def __len__(self): # <<<<<<<<<<<<<<
@@ -6455,7 +7316,7 @@ static Py_ssize_t __pyx_pf_5_cdec_15SufficientStats_2__len__(struct __pyx_obj_5_
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__len__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":43
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":52
*
* def __len__(self):
* return self.stats.size() # <<<<<<<<<<<<<<
@@ -6483,7 +7344,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_5__iter__(PyObject *__pyx_v_s
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":45
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":54
* return self.stats.size()
*
* def __iter__(self): # <<<<<<<<<<<<<<
@@ -6492,14 +7353,14 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_5__iter__(PyObject *__pyx_v_s
*/
static PyObject *__pyx_pf_5_cdec_15SufficientStats_4__iter__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_self) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ *__pyx_cur_scope;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_9___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);
+ __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_9___iter__ *)__pyx_ptype_5_cdec___pyx_scope_struct_9___iter__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_9___iter__, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__Pyx_RefNannyFinishContext();
return NULL;
@@ -6509,7 +7370,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_4__iter__(struct __pyx_obj_5_
__Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
__Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
{
- __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_15SufficientStats_6generator7, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_15SufficientStats_6generator7, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -6529,7 +7390,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_4__iter__(struct __pyx_obj_5_
static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator7(__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);
+ struct __pyx_obj_5_cdec___pyx_scope_struct_9___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_9___iter__ *)__pyx_generator->closure);
PyObject *__pyx_r = NULL;
Py_ssize_t __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
@@ -6546,31 +7407,31 @@ static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator7(__pyx_GeneratorOb
return NULL;
}
__pyx_L3_first_run:;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":46
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":55
*
* def __iter__(self):
* for i in range(len(self)): # <<<<<<<<<<<<<<
* yield self.stats[0][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 = 46; __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[4]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __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[4]; __pyx_lineno = 55; __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 = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __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[4]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __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[4]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
}
@@ -6587,7 +7448,7 @@ static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator7(__pyx_GeneratorOb
if (unlikely(!__pyx_t_2)) {
if (PyErr_Occurred()) {
if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
- else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
break;
}
@@ -6599,15 +7460,15 @@ static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator7(__pyx_GeneratorOb
__pyx_cur_scope->__pyx_v_i = __pyx_t_2;
__pyx_t_2 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":47
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":56
* def __iter__(self):
* for i in range(len(self)):
* yield self.stats[0][i] # <<<<<<<<<<<<<<
*
* def __iadd__(SufficientStats self, SufficientStats other):
*/
- __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_i); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_2 = PyFloat_FromDouble(((__pyx_cur_scope->__pyx_v_self->stats[0])[__pyx_t_5])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_i); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyFloat_FromDouble(((__pyx_cur_scope->__pyx_v_self->stats[0])[__pyx_t_5])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
@@ -6626,7 +7487,7 @@ static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator7(__pyx_GeneratorOb
__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[4]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
PyErr_SetNone(PyExc_StopIteration);
@@ -6648,7 +7509,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_8__iadd__(PyObject *__pyx_v_s
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[4]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SufficientStats, 1, "other", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = __pyx_pf_5_cdec_15SufficientStats_7__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:;
@@ -6658,7 +7519,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_8__iadd__(PyObject *__pyx_v_s
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":49
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":58
* yield self.stats[0][i]
*
* def __iadd__(SufficientStats self, SufficientStats other): # <<<<<<<<<<<<<<
@@ -6671,7 +7532,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_7__iadd__(struct __pyx_obj_5_
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__iadd__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":50
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":59
*
* def __iadd__(SufficientStats self, SufficientStats other):
* self.stats[0] += other.stats[0] # <<<<<<<<<<<<<<
@@ -6680,12 +7541,12 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_7__iadd__(struct __pyx_obj_5_
*/
(__pyx_v_self->stats[0]) += (__pyx_v_other->stats[0]);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":51
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":60
* def __iadd__(SufficientStats self, SufficientStats other):
* self.stats[0] += other.stats[0]
* return self # <<<<<<<<<<<<<<
*
- * def __add__(SufficientStats x, SufficientStats y):
+ * def __add__(x, y):
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(((PyObject *)__pyx_v_self));
@@ -6705,26 +7566,22 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_10__add__(PyObject *__pyx_v_x
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__add__ (wrapper)", 0);
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SufficientStats, 1, "x", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SufficientStats, 1, "y", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_r = __pyx_pf_5_cdec_15SufficientStats_9__add__(((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_v_y));
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = NULL;
- __pyx_L0:;
+ __pyx_r = __pyx_pf_5_cdec_15SufficientStats_9__add__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":53
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":62
* return self
*
- * def __add__(SufficientStats x, SufficientStats y): # <<<<<<<<<<<<<<
- * cdef SufficientStats result = SufficientStats()
- * result.stats = new mteval.SufficientStats(mteval.add(x.stats[0], y.stats[0]))
+ * 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_9__add__(struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_x, struct __pyx_obj_5_cdec_SufficientStats *__pyx_v_y) {
+static PyObject *__pyx_pf_5_cdec_15SufficientStats_9__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
@@ -6734,39 +7591,63 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_9__add__(struct __pyx_obj_5_c
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__add__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":54
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":63
*
- * def __add__(SufficientStats x, SufficientStats y):
+ * 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[4]; __pyx_lineno = 63; __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":64
+ * 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[4]; __pyx_lineno = 64; __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":65
+ * 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(x.stats[0], y.stats[0]))
- * result.metric = x.metric
+ * 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[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SufficientStats)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 65; __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":55
- * def __add__(SufficientStats x, SufficientStats y):
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":66
+ * cdef SufficientStats sy = as_stats(y, x)
* cdef SufficientStats result = SufficientStats()
- * result.stats = new mteval.SufficientStats(mteval.add(x.stats[0], y.stats[0])) # <<<<<<<<<<<<<<
- * result.metric = x.metric
+ * 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_x->stats[0]), (__pyx_v_y->stats[0])));
+ __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":56
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":67
* cdef SufficientStats result = SufficientStats()
- * result.stats = new mteval.SufficientStats(mteval.add(x.stats[0], y.stats[0]))
- * result.metric = x.metric # <<<<<<<<<<<<<<
+ * 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_x->metric;
+ __pyx_v_result->metric = __pyx_v_sx->metric;
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":57
- * result.stats = new mteval.SufficientStats(mteval.add(x.stats[0], y.stats[0]))
- * result.metric = x.metric
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":68
+ * result.stats = new mteval.SufficientStats(mteval.add(sx.stats[0], sy.stats[0]))
+ * result.metric = sx.metric
* return result # <<<<<<<<<<<<<<
*
* cdef class CandidateSet:
@@ -6783,6 +7664,8 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_9__add__(struct __pyx_obj_5_c
__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();
@@ -6815,7 +7698,7 @@ static int __pyx_pw_5_cdec_12CandidateSet_1__cinit__(PyObject *__pyx_v_self, PyO
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __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 = 75; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
goto __pyx_L5_argtuple_error;
@@ -6826,13 +7709,13 @@ static int __pyx_pw_5_cdec_12CandidateSet_1__cinit__(PyObject *__pyx_v_self, PyO
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __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 = 75; __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[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_evaluator), __pyx_ptype_5_cdec_SegmentEvaluator, 1, "evaluator", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 75; __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:;
@@ -6842,7 +7725,7 @@ static int __pyx_pw_5_cdec_12CandidateSet_1__cinit__(PyObject *__pyx_v_self, PyO
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":64
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":75
* cdef mteval.CandidateSet* cs
*
* def __cinit__(self, SegmentEvaluator evaluator): # <<<<<<<<<<<<<<
@@ -6855,7 +7738,7 @@ static int __pyx_pf_5_cdec_12CandidateSet___cinit__(struct __pyx_obj_5_cdec_Cand
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__cinit__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":65
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":76
*
* def __cinit__(self, SegmentEvaluator evaluator):
* self.scorer = new shared_ptr[mteval.SegmentEvaluator](evaluator.scorer[0]) # <<<<<<<<<<<<<<
@@ -6864,7 +7747,7 @@ static int __pyx_pf_5_cdec_12CandidateSet___cinit__(struct __pyx_obj_5_cdec_Cand
*/
__pyx_v_self->scorer = new boost::shared_ptr<SegmentEvaluator>((__pyx_v_evaluator->scorer[0]));
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":66
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":77
* def __cinit__(self, SegmentEvaluator evaluator):
* self.scorer = new shared_ptr[mteval.SegmentEvaluator](evaluator.scorer[0])
* self.metric = evaluator.metric # <<<<<<<<<<<<<<
@@ -6873,7 +7756,7 @@ static int __pyx_pf_5_cdec_12CandidateSet___cinit__(struct __pyx_obj_5_cdec_Cand
*/
__pyx_v_self->metric = __pyx_v_evaluator->metric;
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":67
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":78
* self.scorer = new shared_ptr[mteval.SegmentEvaluator](evaluator.scorer[0])
* self.metric = evaluator.metric
* self.cs = new mteval.CandidateSet() # <<<<<<<<<<<<<<
@@ -6896,7 +7779,7 @@ static void __pyx_pw_5_cdec_12CandidateSet_3__dealloc__(PyObject *__pyx_v_self)
__Pyx_RefNannyFinishContext();
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":69
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":80
* self.cs = new mteval.CandidateSet()
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
@@ -6908,7 +7791,7 @@ static void __pyx_pf_5_cdec_12CandidateSet_2__dealloc__(CYTHON_UNUSED struct __p
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":70
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":81
*
* def __dealloc__(self):
* del self.scorer # <<<<<<<<<<<<<<
@@ -6917,7 +7800,7 @@ static void __pyx_pf_5_cdec_12CandidateSet_2__dealloc__(CYTHON_UNUSED struct __p
*/
delete __pyx_v_self->scorer;
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":71
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":82
* def __dealloc__(self):
* del self.scorer
* del self.cs # <<<<<<<<<<<<<<
@@ -6940,7 +7823,7 @@ static Py_ssize_t __pyx_pw_5_cdec_12CandidateSet_5__len__(PyObject *__pyx_v_self
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":73
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":84
* del self.cs
*
* def __len__(self): # <<<<<<<<<<<<<<
@@ -6953,12 +7836,12 @@ static Py_ssize_t __pyx_pf_5_cdec_12CandidateSet_4__len__(struct __pyx_obj_5_cde
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__len__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":74
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":85
*
* def __len__(self):
* return self.cs.size() # <<<<<<<<<<<<<<
*
- * def __getitem__(self, unsigned k):
+ * def __getitem__(self,int k):
*/
__pyx_r = __pyx_v_self->cs->size();
goto __pyx_L0;
@@ -6972,12 +7855,12 @@ static Py_ssize_t __pyx_pf_5_cdec_12CandidateSet_4__len__(struct __pyx_obj_5_cde
/* 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) {
- unsigned int __pyx_v_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_AsUnsignedInt(__pyx_arg_k); if (unlikely((__pyx_v_k == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_k = __Pyx_PyInt_AsInt(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
@@ -6985,43 +7868,75 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_7__getitem__(PyObject *__pyx_v_s
__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), ((unsigned int)__pyx_v_k));
+ __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":76
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":87
* return self.cs.size()
*
- * def __getitem__(self, unsigned k): # <<<<<<<<<<<<<<
- * cdef Candidate candidate = Candidate()
- * candidate.candidate = &self.cs[0][k]
+ * 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, unsigned int __pyx_v_k) {
+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
- PyObject *__pyx_t_1 = NULL;
+ 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":77
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":88
*
- * def __getitem__(self, unsigned k):
+ * 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":89
+ * 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_36), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 89; __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[4]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":90
+ * 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_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Candidate)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_candidate = ((struct __pyx_obj_5_cdec_Candidate *)__pyx_t_1);
- __pyx_t_1 = 0;
+ __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[4]; __pyx_lineno = 90; __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":78
- * def __getitem__(self, unsigned k):
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":91
+ * 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)
@@ -7029,7 +7944,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_
*/
__pyx_v_candidate->candidate = (&((__pyx_v_self->cs[0])[__pyx_v_k]));
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":79
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":92
* cdef Candidate candidate = Candidate()
* candidate.candidate = &self.cs[0][k]
* candidate.score = self.metric.ComputeScore(self.cs[0][k].eval_feats) # <<<<<<<<<<<<<<
@@ -7038,7 +7953,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_
*/
__pyx_v_candidate->score = __pyx_v_self->metric->ComputeScore(((__pyx_v_self->cs[0])[__pyx_v_k]).eval_feats);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":80
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":93
* candidate.candidate = &self.cs[0][k]
* candidate.score = self.metric.ComputeScore(self.cs[0][k].eval_feats)
* return candidate # <<<<<<<<<<<<<<
@@ -7053,7 +7968,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_
__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.CandidateSet.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
@@ -7075,7 +7990,7 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_9__iter__(PyObject *__pyx_v_self
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":82
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":95
* return candidate
*
* def __iter__(self): # <<<<<<<<<<<<<<
@@ -7084,14 +7999,14 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_9__iter__(PyObject *__pyx_v_self
*/
static PyObject *__pyx_pf_5_cdec_12CandidateSet_8__iter__(struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__ *__pyx_cur_scope;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_10___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_8___iter__ *)__pyx_ptype_5_cdec___pyx_scope_struct_8___iter__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_8___iter__, __pyx_empty_tuple, NULL);
+ __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_10___iter__ *)__pyx_ptype_5_cdec___pyx_scope_struct_10___iter__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_10___iter__, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__Pyx_RefNannyFinishContext();
return NULL;
@@ -7101,7 +8016,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_8__iter__(struct __pyx_obj_5_cde
__Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
__Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
{
- __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_12CandidateSet_10generator8, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_12CandidateSet_10generator8, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -7121,7 +8036,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_8__iter__(struct __pyx_obj_5_cde
static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator8(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
- struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__ *)__pyx_generator->closure);
+ struct __pyx_obj_5_cdec___pyx_scope_struct_10___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_10___iter__ *)__pyx_generator->closure);
PyObject *__pyx_r = NULL;
Py_ssize_t __pyx_t_1;
unsigned int __pyx_t_2;
@@ -7136,27 +8051,27 @@ static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator8(__pyx_GeneratorObje
return NULL;
}
__pyx_L3_first_run:;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":84
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":97
* 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 = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 97; __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":85
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":98
* 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[4]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
@@ -7170,7 +8085,7 @@ static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator8(__pyx_GeneratorObje
__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 = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
@@ -7214,11 +8129,11 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_12add_kbest(PyObject *__pyx_v_se
values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__k);
if (likely(values[1])) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("add_kbest", 1, 2, 2, 1); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("add_kbest", 1, 2, 2, 1); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 100; __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[4]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_kbest") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
@@ -7227,17 +8142,17 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_12add_kbest(PyObject *__pyx_v_se
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[4]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_k = __Pyx_PyInt_AsUnsignedInt(values[1]); if (unlikely((__pyx_v_k == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 100; __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[4]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("add_kbest", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 100; __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[4]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hypergraph), __pyx_ptype_5_cdec_Hypergraph, 1, "hypergraph", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 100; __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:;
@@ -7247,7 +8162,7 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_12add_kbest(PyObject *__pyx_v_se
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":87
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":100
* yield self[i]
*
* def add_kbest(self, Hypergraph hypergraph, unsigned k): # <<<<<<<<<<<<<<
@@ -7260,7 +8175,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_11add_kbest(struct __pyx_obj_5_c
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("add_kbest", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":88
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":101
*
* def add_kbest(self, Hypergraph hypergraph, unsigned k):
* self.cs.AddKBestCandidates(hypergraph.hg[0], k, self.scorer.get()) # <<<<<<<<<<<<<<
@@ -7284,7 +8199,7 @@ static void __pyx_pw_5_cdec_16SegmentEvaluator_1__dealloc__(PyObject *__pyx_v_se
__Pyx_RefNannyFinishContext();
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":94
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":107
* cdef mteval.EvaluationMetric* metric
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
@@ -7296,7 +8211,7 @@ static void __pyx_pf_5_cdec_16SegmentEvaluator___dealloc__(CYTHON_UNUSED struct
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":95
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":108
*
* def __dealloc__(self):
* del self.scorer # <<<<<<<<<<<<<<
@@ -7319,7 +8234,7 @@ static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_3evaluate(PyObject *__pyx_v_
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":97
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":110
* del self.scorer
*
* def evaluate(self, sentence): # <<<<<<<<<<<<<<
@@ -7339,19 +8254,19 @@ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_2evaluate(struct __pyx_obj_5
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("evaluate", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":99
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":112
* 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[4]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SufficientStats)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 112; __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":100
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":113
* cdef vector[WordID] hyp
* cdef SufficientStats sf = SufficientStats()
* sf.metric = self.metric # <<<<<<<<<<<<<<
@@ -7360,7 +8275,7 @@ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_2evaluate(struct __pyx_obj_5
*/
__pyx_v_sf->metric = __pyx_v_self->metric;
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":101
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":114
* cdef SufficientStats sf = SufficientStats()
* sf.metric = self.metric
* sf.stats = new mteval.SufficientStats() # <<<<<<<<<<<<<<
@@ -7369,22 +8284,22 @@ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_2evaluate(struct __pyx_obj_5
*/
__pyx_v_sf->stats = new SufficientStats();
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":102
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":115
* 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[4]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 115; __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[4]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 115; __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":103
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":116
* sf.stats = new mteval.SufficientStats()
* ConvertSentence(string(as_str(sentence.strip())), &hyp)
* self.scorer.get().Evaluate(hyp, sf.stats) # <<<<<<<<<<<<<<
@@ -7393,7 +8308,7 @@ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_2evaluate(struct __pyx_obj_5
*/
__pyx_v_self->scorer->get()->Evaluate(__pyx_v_hyp, __pyx_v_sf->stats);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":104
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":117
* ConvertSentence(string(as_str(sentence.strip())), &hyp)
* self.scorer.get().Evaluate(hyp, sf.stats)
* return sf # <<<<<<<<<<<<<<
@@ -7430,7 +8345,7 @@ static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_5candidate_set(PyObject *__p
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":106
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":119
* return sf
*
* def candidate_set(self): # <<<<<<<<<<<<<<
@@ -7448,7 +8363,7 @@ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_4candidate_set(struct __pyx_
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("candidate_set", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":107
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":120
*
* def candidate_set(self):
* return CandidateSet(self) # <<<<<<<<<<<<<<
@@ -7456,12 +8371,12 @@ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_4candidate_set(struct __pyx_
* cdef class Scorer:
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(((PyObject *)__pyx_v_self));
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
__Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_CandidateSet)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 107; __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[4]; __pyx_lineno = 120; __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;
@@ -7507,18 +8422,18 @@ static int __pyx_pw_5_cdec_6Scorer_1__cinit__(PyObject *__pyx_v_self, PyObject *
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 112; __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 = 125; __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_name = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_name = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 125; __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[4]; __pyx_lineno = 112; __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 = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("_cdec.Scorer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
@@ -7529,7 +8444,7 @@ static int __pyx_pw_5_cdec_6Scorer_1__cinit__(PyObject *__pyx_v_self, PyObject *
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":112
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":125
* cdef string* name
*
* def __cinit__(self, char* name): # <<<<<<<<<<<<<<
@@ -7542,7 +8457,7 @@ static int __pyx_pf_5_cdec_6Scorer___cinit__(struct __pyx_obj_5_cdec_Scorer *__p
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__cinit__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":113
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":126
*
* def __cinit__(self, char* name):
* self.name = new string(name) # <<<<<<<<<<<<<<
@@ -7565,7 +8480,7 @@ static void __pyx_pw_5_cdec_6Scorer_3__dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannyFinishContext();
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":115
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":128
* self.name = new string(name)
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
@@ -7577,7 +8492,7 @@ static void __pyx_pf_5_cdec_6Scorer_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":116
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":129
*
* def __dealloc__(self):
* del self.name # <<<<<<<<<<<<<<
@@ -7615,7 +8530,7 @@ static PyObject *__pyx_pw_5_cdec_6Scorer_5__call__(PyObject *__pyx_v_self, PyObj
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
goto __pyx_L5_argtuple_error;
@@ -7626,7 +8541,7 @@ static PyObject *__pyx_pw_5_cdec_6Scorer_5__call__(PyObject *__pyx_v_self, PyObj
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("_cdec.Scorer.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
@@ -7637,7 +8552,7 @@ static PyObject *__pyx_pw_5_cdec_6Scorer_5__call__(PyObject *__pyx_v_self, PyObj
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":118
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":131
* del self.name
*
* def __call__(self, refs): # <<<<<<<<<<<<<<
@@ -7667,7 +8582,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
__Pyx_RefNannySetupContext("__call__", 0);
__Pyx_INCREF(__pyx_v_refs);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":119
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":132
*
* def __call__(self, refs):
* cdef mteval.EvaluationMetric* metric = mteval.Instance(self.name[0]) # <<<<<<<<<<<<<<
@@ -7676,7 +8591,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
*/
__pyx_v_metric = EvaluationMetric::Instance((__pyx_v_self->name[0]));
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":120
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":133
* def __call__(self, refs):
* cdef mteval.EvaluationMetric* metric = mteval.Instance(self.name[0])
* if isinstance(refs, unicode) or isinstance(refs, str): # <<<<<<<<<<<<<<
@@ -7698,14 +8613,14 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
}
if (__pyx_t_4) {
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":121
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":134
* cdef mteval.EvaluationMetric* metric = mteval.Instance(self.name[0])
* 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[4]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 134; __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);
@@ -7717,7 +8632,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
}
__pyx_L3:;
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":122
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":135
* if isinstance(refs, unicode) or isinstance(refs, str):
* refs = [refs]
* cdef vector[vector[WordID]]* refsv = new vector[vector[WordID]]() # <<<<<<<<<<<<<<
@@ -7726,7 +8641,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
*/
__pyx_v_refsv = new std::vector<std::vector<WordID> >();
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":125
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":138
* cdef vector[WordID]* refv
* cdef bytes ref_str
* for ref in refs: # <<<<<<<<<<<<<<
@@ -7737,7 +8652,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
__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[4]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_refs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext;
}
@@ -7753,7 +8668,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
if (unlikely(!__pyx_t_7)) {
if (PyErr_Occurred()) {
if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
- else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
break;
}
@@ -7763,7 +8678,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
__pyx_v_ref = __pyx_t_7;
__pyx_t_7 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":126
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":139
* cdef bytes ref_str
* for ref in refs:
* refv = new vector[WordID]() # <<<<<<<<<<<<<<
@@ -7772,22 +8687,22 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
*/
__pyx_v_refv = new std::vector<WordID>();
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":127
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":140
* 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[4]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = PyObject_GetAttr(__pyx_v_ref, __pyx_n_s__strip); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 140; __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[4]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
TD::ConvertSentence(std::string(__pyx_f_5_cdec_as_str(__pyx_t_8, NULL)), __pyx_v_refv);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":128
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":141
* refv = new vector[WordID]()
* ConvertSentence(string(as_str(ref.strip())), refv)
* refsv.push_back(refv[0]) # <<<<<<<<<<<<<<
@@ -7796,7 +8711,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
*/
__pyx_v_refsv->push_back((__pyx_v_refv[0]));
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":129
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":142
* ConvertSentence(string(as_str(ref.strip())), refv)
* refsv.push_back(refv[0])
* del refv # <<<<<<<<<<<<<<
@@ -7807,19 +8722,19 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":131
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":144
* del refv
* cdef unsigned i
* cdef SegmentEvaluator evaluator = SegmentEvaluator() # <<<<<<<<<<<<<<
* evaluator.metric = metric
* evaluator.scorer = new shared_ptr[mteval.SegmentEvaluator](metric.CreateSegmentEvaluator(refsv[0]))
*/
- __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[4]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SegmentEvaluator)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_evaluator = ((struct __pyx_obj_5_cdec_SegmentEvaluator *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":132
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":145
* cdef unsigned i
* cdef SegmentEvaluator evaluator = SegmentEvaluator()
* evaluator.metric = metric # <<<<<<<<<<<<<<
@@ -7828,7 +8743,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
*/
__pyx_v_evaluator->metric = __pyx_v_metric;
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":133
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":146
* cdef SegmentEvaluator evaluator = SegmentEvaluator()
* evaluator.metric = metric
* evaluator.scorer = new shared_ptr[mteval.SegmentEvaluator](metric.CreateSegmentEvaluator(refsv[0])) # <<<<<<<<<<<<<<
@@ -7837,7 +8752,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
*/
__pyx_v_evaluator->scorer = new boost::shared_ptr<SegmentEvaluator>(__pyx_v_metric->CreateSegmentEvaluator((__pyx_v_refsv[0])));
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":134
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":147
* evaluator.metric = metric
* evaluator.scorer = new shared_ptr[mteval.SegmentEvaluator](metric.CreateSegmentEvaluator(refsv[0]))
* del refsv # in theory should not delete but store in SegmentEvaluator # <<<<<<<<<<<<<<
@@ -7846,7 +8761,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score
*/
delete __pyx_v_refsv;
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":135
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":148
* evaluator.scorer = new shared_ptr[mteval.SegmentEvaluator](metric.CreateSegmentEvaluator(refsv[0]))
* del refsv # in theory should not delete but store in SegmentEvaluator
* return evaluator # <<<<<<<<<<<<<<
@@ -7886,7 +8801,7 @@ static PyObject *__pyx_pw_5_cdec_6Scorer_7__str__(PyObject *__pyx_v_self) {
return __pyx_r;
}
-/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":137
+/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":150
* return evaluator
*
* def __str__(self): # <<<<<<<<<<<<<<
@@ -7903,7 +8818,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_6__str__(struct __pyx_obj_5_cdec_Scorer
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__str__", 0);
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":138
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":151
*
* def __str__(self):
* return self.name.c_str() # <<<<<<<<<<<<<<
@@ -7911,7 +8826,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_6__str__(struct __pyx_obj_5_cdec_Scorer
* BLEU = Scorer('IBM_BLEU')
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyBytes_FromString(__pyx_v_self->name->c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_FromString(__pyx_v_self->name->c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
__pyx_r = ((PyObject *)__pyx_t_1);
__pyx_t_1 = 0;
@@ -7978,7 +8893,7 @@ static int __pyx_pw_5_cdec_7Decoder_1__cinit__(PyObject *__pyx_v_self, PyObject
}
/* "_cdec.pyx":19
- * cdef public DenseVector weights
+ * cdef DenseVector weights
*
* def __cinit__(self, char* config): # <<<<<<<<<<<<<<
* decoder.register_feature_functions()
@@ -8092,7 +9007,7 @@ static void __pyx_pf_5_cdec_7Decoder_2__dealloc__(CYTHON_UNUSED struct __pyx_obj
* def __dealloc__(self):
* del self.dec # <<<<<<<<<<<<<<
*
- * def read_weights(self, cfg):
+ * property weights:
*/
delete __pyx_v_self->dec;
@@ -8100,6 +9015,299 @@ static void __pyx_pf_5_cdec_7Decoder_2__dealloc__(CYTHON_UNUSED struct __pyx_obj
}
/* 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":31
+ *
+ * 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":32
+ * 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;
+}
+
+/* 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":34
+ * 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":35
+ *
+ * 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":36
+ * 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":37
+ * 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":38
+ * 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":39
+ * elif isinstance(weights, SparseVector):
+ * self.weights.vector.clear()
+ * ((<SparseVector> weights).vector[0]).init_vector(self.weights.vector) # <<<<<<<<<<<<<<
+ * elif isinstance(weights, dict):
+ * for fname, fval in weights.items():
+ */
+ (((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_weights)->vector[0]).init_vector(__pyx_v_self->weights->vector);
+ goto __pyx_L3;
+ }
+
+ /* "_cdec.pyx":40
+ * self.weights.vector.clear()
+ * ((<SparseVector> weights).vector[0]).init_vector(self.weights.vector)
+ * elif isinstance(weights, dict): # <<<<<<<<<<<<<<
+ * for fname, fval in weights.items():
+ * self.weights[fname] = fval
+ */
+ __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":41
+ * ((<SparseVector> weights).vector[0]).init_vector(self.weights.vector)
+ * elif isinstance(weights, dict):
+ * 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 = 41; __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 = 41; __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 = 41; __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;
+ __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
+ } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) {
+ if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+ __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
+ } 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 = 41; __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 (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 = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
+ __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1);
+ } else {
+ if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
+ if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
+ else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ __pyx_t_6 = PyList_GET_ITEM(sequence, 0);
+ __pyx_t_7 = PyList_GET_ITEM(sequence, 1);
+ }
+ __Pyx_INCREF(__pyx_t_6);
+ __Pyx_INCREF(__pyx_t_7);
+ __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 = 41; __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 = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+ goto __pyx_L7_unpacking_done;
+ __pyx_L6_unpacking_failed:;
+ __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+ if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
+ if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __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":42
+ * elif isinstance(weights, dict):
+ * 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 = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ }
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ goto __pyx_L3;
+ }
+ /*else*/ {
+
+ /* "_cdec.pyx":44
+ * self.weights[fname] = fval
+ * else:
+ * raise TypeError('cannot initialize weights with %s' % type(weights)) # <<<<<<<<<<<<<<
+ *
+ * def read_weights(self, cfg):
+ */
+ __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_37), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __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 = 44; __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 = 44; __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 = 44; __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_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) {
PyObject *__pyx_r = 0;
@@ -8110,8 +9318,8 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_5read_weights(PyObject *__pyx_v_self,
return __pyx_r;
}
-/* "_cdec.pyx":30
- * del self.dec
+/* "_cdec.pyx":46
+ * raise TypeError('cannot initialize weights with %s' % type(weights))
*
* def read_weights(self, cfg): # <<<<<<<<<<<<<<
* with open(cfg) as fp:
@@ -8146,7 +9354,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("read_weights", 0);
- /* "_cdec.pyx":31
+ /* "_cdec.pyx":47
*
* def read_weights(self, cfg):
* with open(cfg) as fp: # <<<<<<<<<<<<<<
@@ -8154,19 +9362,19 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
* fname, value = line.split()
*/
/*with:*/ {
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __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 = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __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 = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____exit__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __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 = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s____enter__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __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 = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __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;
@@ -8181,7 +9389,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__pyx_v_fp = __pyx_t_4;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- /* "_cdec.pyx":32
+ /* "_cdec.pyx":48
* def read_weights(self, cfg):
* with open(cfg) as fp:
* for line in fp: # <<<<<<<<<<<<<<
@@ -8192,7 +9400,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__pyx_t_4 = __pyx_v_fp; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0;
__pyx_t_9 = NULL;
} else {
- __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_fp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_fp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext;
}
@@ -8208,7 +9416,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
if (unlikely(!__pyx_t_2)) {
if (PyErr_Occurred()) {
if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
- else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
}
break;
}
@@ -8218,16 +9426,16 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__pyx_v_line = __pyx_t_2;
__pyx_t_2 = 0;
- /* "_cdec.pyx":33
+ /* "_cdec.pyx":49
* with open(cfg) as fp:
* for line in fp:
* fname, value = line.split() # <<<<<<<<<<<<<<
* self.weights[fname.strip()] = float(value)
*
*/
- __pyx_t_2 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__split); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_2 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__split); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __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 = 33; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __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))) {
@@ -8236,7 +9444,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
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 = 33; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
}
__pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_10 = PyTuple_GET_ITEM(sequence, 1);
@@ -8244,7 +9452,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
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 = 33; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
}
__pyx_t_2 = PyList_GET_ITEM(sequence, 0);
__pyx_t_10 = PyList_GET_ITEM(sequence, 1);
@@ -8254,7 +9462,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__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 = 33; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __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;
@@ -8262,14 +9470,14 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__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 = 33; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __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 = 33; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
__pyx_L19_unpacking_done:;
}
__Pyx_XDECREF(__pyx_v_fname);
@@ -8279,22 +9487,22 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__pyx_v_value = __pyx_t_10;
__pyx_t_10 = 0;
- /* "_cdec.pyx":34
+ /* "_cdec.pyx":50
* for line in fp:
* fname, value = line.split()
* self.weights[fname.strip()] = float(value) # <<<<<<<<<<<<<<
*
* def translate(self, sentence, grammar=None):
*/
- __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 = 34; __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 = 34; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __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 = 50; __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 = 50; __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 = 34; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __pyx_t_10 = PyObject_GetAttr(__pyx_v_fname, __pyx_n_s__strip); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __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 = 34; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ __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 = 50; __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 = 34; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+ if (PyObject_SetItem(((PyObject *)__pyx_v_self->weights), __pyx_t_2, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __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;
}
@@ -8311,7 +9519,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- /* "_cdec.pyx":31
+ /* "_cdec.pyx":47
*
* def read_weights(self, cfg):
* with open(cfg) as fp: # <<<<<<<<<<<<<<
@@ -8320,11 +9528,11 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
*/
/*except:*/ {
__Pyx_AddTraceback("_cdec.Decoder.read_weights", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+ if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __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 = 31; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+ __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __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);
@@ -8337,11 +9545,11 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__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 = 31; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+ if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __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 = 31; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+ if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
__pyx_t_16 = (!__pyx_t_14);
if (__pyx_t_16) {
__Pyx_GIVEREF(__pyx_t_4);
@@ -8349,7 +9557,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
__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 = 31; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
goto __pyx_L22;
}
__pyx_L22:;
@@ -8375,13 +9583,13 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_
}
/*finally:*/ {
if (__pyx_t_3) {
- __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_21, NULL);
+ __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_38, NULL);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __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 = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
goto __pyx_L23;
@@ -8423,7 +9631,7 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyO
{
PyObject* values[2] = {0,0};
- /* "_cdec.pyx":36
+ /* "_cdec.pyx":52
* self.weights[fname.strip()] = float(value)
*
* def translate(self, sentence, grammar=None): # <<<<<<<<<<<<<<
@@ -8453,7 +9661,7 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyO
}
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "translate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "translate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -8468,7 +9676,7 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyO
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("translate", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("translate", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("_cdec.Decoder.translate", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
@@ -8494,7 +9702,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("translate", 0);
- /* "_cdec.pyx":37
+ /* "_cdec.pyx":53
*
* def translate(self, sentence, grammar=None):
* if isinstance(sentence, unicode): # <<<<<<<<<<<<<<
@@ -8507,22 +9715,22 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_2) {
- /* "_cdec.pyx":38
+ /* "_cdec.pyx":54
* def translate(self, sentence, grammar=None):
* if isinstance(sentence, unicode):
* inp = sentence.strip().encode('utf8') # <<<<<<<<<<<<<<
* elif isinstance(sentence, str):
* inp = sentence.strip()
*/
- __pyx_t_1 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __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 = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__encode); 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);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_22), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_39), 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_v_inp = __pyx_t_3;
@@ -8530,7 +9738,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
goto __pyx_L3;
}
- /* "_cdec.pyx":39
+ /* "_cdec.pyx":55
* if isinstance(sentence, unicode):
* inp = sentence.strip().encode('utf8')
* elif isinstance(sentence, str): # <<<<<<<<<<<<<<
@@ -8543,16 +9751,16 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
if (__pyx_t_2) {
- /* "_cdec.pyx":40
+ /* "_cdec.pyx":56
* inp = sentence.strip().encode('utf8')
* elif isinstance(sentence, str):
* inp = sentence.strip() # <<<<<<<<<<<<<<
* elif isinstance(sentence, Lattice):
* inp = str(sentence) # PLF format
*/
- __pyx_t_3 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__strip); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__strip); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_inp = __pyx_t_1;
@@ -8560,7 +9768,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
goto __pyx_L3;
}
- /* "_cdec.pyx":41
+ /* "_cdec.pyx":57
* elif isinstance(sentence, str):
* inp = sentence.strip()
* elif isinstance(sentence, Lattice): # <<<<<<<<<<<<<<
@@ -8573,19 +9781,19 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_2) {
- /* "_cdec.pyx":42
+ /* "_cdec.pyx":58
* inp = sentence.strip()
* elif isinstance(sentence, Lattice):
* inp = 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 = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __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_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__pyx_v_inp = __pyx_t_3;
@@ -8594,53 +9802,53 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
}
/*else*/ {
- /* "_cdec.pyx":44
+ /* "_cdec.pyx":60
* inp = str(sentence) # PLF format
* else:
* raise TypeError('Cannot translate input type %s' % type(sentence)) # <<<<<<<<<<<<<<
* if grammar:
* self.dec.SetSentenceGrammarFromString(string(<char *> grammar))
*/
- __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_23), ((PyObject *)Py_TYPE(__pyx_v_sentence))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_40), ((PyObject *)Py_TYPE(__pyx_v_sentence))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3));
__Pyx_GIVEREF(((PyObject *)__pyx_t_3));
__pyx_t_3 = 0;
- __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_L3:;
- /* "_cdec.pyx":45
+ /* "_cdec.pyx":61
* else:
* raise TypeError('Cannot translate input type %s' % type(sentence))
* if grammar: # <<<<<<<<<<<<<<
* self.dec.SetSentenceGrammarFromString(string(<char *> grammar))
* cdef decoder.BasicObserver observer = decoder.BasicObserver()
*/
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_grammar); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_grammar); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__pyx_t_2) {
- /* "_cdec.pyx":46
+ /* "_cdec.pyx":62
* raise TypeError('Cannot translate input type %s' % type(sentence))
* if grammar:
* self.dec.SetSentenceGrammarFromString(string(<char *> grammar)) # <<<<<<<<<<<<<<
* cdef decoder.BasicObserver observer = decoder.BasicObserver()
* self.dec.Decode(string(<char *>inp), &observer)
*/
- __pyx_t_4 = PyBytes_AsString(__pyx_v_grammar); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyBytes_AsString(__pyx_v_grammar); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_self->dec->SetSentenceGrammarFromString(std::string(((char *)__pyx_t_4)));
goto __pyx_L4;
}
__pyx_L4:;
- /* "_cdec.pyx":47
+ /* "_cdec.pyx":63
* if grammar:
* self.dec.SetSentenceGrammarFromString(string(<char *> grammar))
* cdef decoder.BasicObserver observer = decoder.BasicObserver() # <<<<<<<<<<<<<<
@@ -8649,17 +9857,17 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
*/
__pyx_v_observer = BasicObserver();
- /* "_cdec.pyx":48
+ /* "_cdec.pyx":64
* self.dec.SetSentenceGrammarFromString(string(<char *> grammar))
* cdef decoder.BasicObserver observer = decoder.BasicObserver()
* self.dec.Decode(string(<char *>inp), &observer) # <<<<<<<<<<<<<<
* if observer.hypergraph == NULL:
* raise ParseFailed()
*/
- __pyx_t_4 = PyBytes_AsString(__pyx_v_inp); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyBytes_AsString(__pyx_v_inp); if (unlikely((!__pyx_t_4) && 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_4)), (&__pyx_v_observer));
- /* "_cdec.pyx":49
+ /* "_cdec.pyx":65
* cdef decoder.BasicObserver observer = decoder.BasicObserver()
* self.dec.Decode(string(<char *>inp), &observer)
* if observer.hypergraph == NULL: # <<<<<<<<<<<<<<
@@ -8669,38 +9877,38 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
__pyx_t_2 = (__pyx_v_observer.hypergraph == NULL);
if (__pyx_t_2) {
- /* "_cdec.pyx":50
+ /* "_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])
*/
- __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ParseFailed); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ParseFailed); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__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 = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L5;
}
__pyx_L5:;
- /* "_cdec.pyx":51
+ /* "_cdec.pyx":67
* if observer.hypergraph == NULL:
* raise ParseFailed()
* cdef Hypergraph hg = Hypergraph() # <<<<<<<<<<<<<<
* hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0])
* return hg
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Hypergraph)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Hypergraph)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_hg = ((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_t_1);
__pyx_t_1 = 0;
- /* "_cdec.pyx":52
+ /* "_cdec.pyx":68
* raise ParseFailed()
* cdef Hypergraph hg = Hypergraph()
* hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0]) # <<<<<<<<<<<<<<
@@ -8708,7 +9916,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
*/
__pyx_v_hg->hg = new Hypergraph((__pyx_v_observer.hypergraph[0]));
- /* "_cdec.pyx":53
+ /* "_cdec.pyx":69
* cdef Hypergraph hg = Hypergraph()
* hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0])
* return hg # <<<<<<<<<<<<<<
@@ -8733,102 +9941,6 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec
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) {
- 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":17
- * cdef class Decoder:
- * cdef decoder.Decoder* dec
- * cdef public DenseVector weights # <<<<<<<<<<<<<<
- *
- * def __cinit__(self, char* config):
- */
-
-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);
- __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;
-}
-
-/* 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) {
- 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_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) {
- 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_DenseVector))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __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_DenseVector *)__pyx_v_value);
-
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("_cdec.Decoder.weights.__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_7Decoder_7weights_5__del__(PyObject *__pyx_v_self); /*proto*/
-static int __pyx_pw_5_cdec_7Decoder_7weights_5__del__(PyObject *__pyx_v_self) {
- 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_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_pf_5_cdec_7Decoder_7weights_4__del__(struct __pyx_obj_5_cdec_Decoder *__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->weights);
- __Pyx_DECREF(((PyObject *)__pyx_v_self->weights));
- __pyx_v_self->weights = ((struct __pyx_obj_5_cdec_DenseVector *)Py_None);
-
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
static PyObject *__pyx_tp_new_5_cdec_DenseVector(PyTypeObject *t, PyObject *a, PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
@@ -9061,16 +10173,16 @@ static PyMethodDef __pyx_methods_5_cdec_SparseVector[] = {
};
static PyNumberMethods __pyx_tp_as_number_SparseVector = {
- __pyx_pw_5_cdec_12SparseVector_28__add__, /*nb_add*/
- __pyx_pw_5_cdec_12SparseVector_30__sub__, /*nb_subtract*/
- __pyx_pw_5_cdec_12SparseVector_32__mul__, /*nb_multiply*/
+ __pyx_pw_5_cdec_12SparseVector_30__add__, /*nb_add*/
+ __pyx_pw_5_cdec_12SparseVector_32__sub__, /*nb_subtract*/
+ __pyx_pw_5_cdec_12SparseVector_34__mul__, /*nb_multiply*/
#if PY_MAJOR_VERSION < 3
- __pyx_pw_5_cdec_12SparseVector_34__div__, /*nb_divide*/
+ __pyx_pw_5_cdec_12SparseVector_36__div__, /*nb_divide*/
#endif
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
- 0, /*nb_negative*/
+ __pyx_pw_5_cdec_12SparseVector_20__neg__, /*nb_negative*/
0, /*nb_positive*/
0, /*nb_absolute*/
0, /*nb_nonzero*/
@@ -9096,11 +10208,11 @@ static PyNumberMethods __pyx_tp_as_number_SparseVector = {
#if PY_MAJOR_VERSION < 3
0, /*nb_hex*/
#endif
- __pyx_pw_5_cdec_12SparseVector_20__iadd__, /*nb_inplace_add*/
- __pyx_pw_5_cdec_12SparseVector_22__isub__, /*nb_inplace_subtract*/
- __pyx_pw_5_cdec_12SparseVector_24__imul__, /*nb_inplace_multiply*/
+ __pyx_pw_5_cdec_12SparseVector_22__iadd__, /*nb_inplace_add*/
+ __pyx_pw_5_cdec_12SparseVector_24__isub__, /*nb_inplace_subtract*/
+ __pyx_pw_5_cdec_12SparseVector_26__imul__, /*nb_inplace_multiply*/
#if PY_MAJOR_VERSION < 3
- __pyx_pw_5_cdec_12SparseVector_26__idiv__, /*nb_inplace_divide*/
+ __pyx_pw_5_cdec_12SparseVector_28__idiv__, /*nb_inplace_divide*/
#endif
0, /*nb_inplace_remainder*/
0, /*nb_inplace_power*/
@@ -9441,6 +10553,7 @@ static int __pyx_mp_ass_subscript_5_cdec_Lattice(PyObject *o, PyObject *i, PyObj
}
static PyMethodDef __pyx_methods_5_cdec_Lattice[] = {
+ {__Pyx_NAMESTR("todot"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_16todot, METH_NOARGS, __Pyx_DOCSTR(0)},
{0, 0, 0, 0}
};
@@ -10587,7 +11700,8 @@ static int __pyx_setprop_5_cdec_7Decoder_weights(PyObject *o, PyObject *v, void
return __pyx_pw_5_cdec_7Decoder_7weights_3__set__(o, v);
}
else {
- return __pyx_pw_5_cdec_7Decoder_7weights_5__del__(o);
+ PyErr_SetString(PyExc_NotImplementedError, "__del__");
+ return -1;
}
}
@@ -12149,28 +13263,458 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_6___iter__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_7___iter__(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ *p;
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_7_todot(PyTypeObject *t, PyObject *a, PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_7_todot *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_7_todot *)o);
+ p->__pyx_v_self = 0;
+ return o;
+}
+
+static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_7_todot(PyObject *o) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_7_todot *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_7_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_7_todot(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_7_todot *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_7_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_7_todot(PyObject *o) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_7_todot *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_7_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_7_todot[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_7_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_7_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_7_todot = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_7_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_7_todot = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_7_todot"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_7_todot), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_7_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_7_todot, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_7_todot, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_7_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_7_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_7_todot, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_7_todot, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_7_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_7_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_8_lines(PyTypeObject *t, PyObject *a, PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_8_lines *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 = ((struct __pyx_obj_5_cdec___pyx_scope_struct_8_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_8_lines(PyObject *o) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_8_lines *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_8_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_8_lines(PyObject *o, visitproc v, void *a) {
+ int e;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_8_lines *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_8_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_8_lines(PyObject *o) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_8_lines *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_8_lines *)o;
+ PyObject* tmp;
+ tmp = ((PyObject*)p->__pyx_outer_scope);
+ p->__pyx_outer_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_7_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_8_lines[] = {
+ {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_8_lines = {
+ 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_8_lines = {
+ 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_8_lines = {
+ 0, /*mp_length*/
+ 0, /*mp_subscript*/
+ 0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_8_lines = {
+ #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_8_lines = {
+ PyVarObject_HEAD_INIT(0, 0)
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_8_lines"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_8_lines), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_8_lines, /*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_8_lines, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_8_lines, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_8_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_8_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_8_lines, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_8_lines, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ __pyx_methods_5_cdec___pyx_scope_struct_8_lines, /*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_8_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_9___iter__(PyTypeObject *t, PyObject *a, PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_9___iter__ *p;
+ PyObject *o = (*t->tp_alloc)(t, 0);
+ if (!o) return 0;
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_9___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_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;
+static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_9___iter__(PyObject *o) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_9___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_9___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_7___iter__(PyObject *o, visitproc v, void *a) {
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_9___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;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_9___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_9___iter__ *)o;
if (p->__pyx_v_i) {
e = (*v)(p->__pyx_v_i, a); if (e) return e;
}
@@ -12183,8 +13727,8 @@ static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_7___iter__(PyObject *o, v
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;
+static int __pyx_tp_clear_5_cdec___pyx_scope_struct_9___iter__(PyObject *o) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_9___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_9___iter__ *)o;
PyObject* tmp;
tmp = ((PyObject*)p->__pyx_v_i);
p->__pyx_v_i = Py_None; Py_INCREF(Py_None);
@@ -12198,11 +13742,11 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_7___iter__(PyObject *o) {
return 0;
}
-static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_7___iter__[] = {
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_9___iter__[] = {
{0, 0, 0, 0}
};
-static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_7___iter__ = {
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_9___iter__ = {
0, /*nb_add*/
0, /*nb_subtract*/
0, /*nb_multiply*/
@@ -12260,7 +13804,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_7___iter__ = {
#endif
};
-static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_7___iter__ = {
+static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_9___iter__ = {
0, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
@@ -12273,13 +13817,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_7___iter__ = {
0, /*sq_inplace_repeat*/
};
-static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_7___iter__ = {
+static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_9___iter__ = {
0, /*mp_length*/
0, /*mp_subscript*/
0, /*mp_ass_subscript*/
};
-static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_7___iter__ = {
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_9___iter__ = {
#if PY_MAJOR_VERSION < 3
0, /*bf_getreadbuffer*/
#endif
@@ -12300,12 +13844,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_7___iter__ = {
#endif
};
-static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_7___iter__ = {
+static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_9___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*/
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_9___iter__"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_9___iter__), /*tp_basicsize*/
0, /*tp_itemsize*/
- __pyx_tp_dealloc_5_cdec___pyx_scope_struct_7___iter__, /*tp_dealloc*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_9___iter__, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
@@ -12315,24 +13859,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_7___iter__ = {
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*/
+ &__pyx_tp_as_number___pyx_scope_struct_9___iter__, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_9___iter__, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_9___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*/
+ &__pyx_tp_as_buffer___pyx_scope_struct_9___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*/
+ __pyx_tp_traverse_5_cdec___pyx_scope_struct_9___iter__, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_9___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*/
+ __pyx_methods_5_cdec___pyx_scope_struct_9___iter__, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
0, /*tp_base*/
@@ -12342,7 +13886,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_7___iter__ = {
0, /*tp_dictoffset*/
0, /*tp_init*/
0, /*tp_alloc*/
- __pyx_tp_new_5_cdec___pyx_scope_struct_7___iter__, /*tp_new*/
+ __pyx_tp_new_5_cdec___pyx_scope_struct_9___iter__, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
@@ -12356,32 +13900,32 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_7___iter__ = {
#endif
};
-static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_8___iter__(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__ *p;
+static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_10___iter__(PyTypeObject *t, PyObject *a, PyObject *k) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_10___iter__ *p;
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
- p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__ *)o);
+ p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_10___iter__ *)o);
p->__pyx_v_self = 0;
return o;
}
-static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_8___iter__(PyObject *o) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__ *)o;
+static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_10___iter__(PyObject *o) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_10___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_10___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_8___iter__(PyObject *o, visitproc v, void *a) {
+static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_10___iter__(PyObject *o, visitproc v, void *a) {
int e;
- struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__ *)o;
+ struct __pyx_obj_5_cdec___pyx_scope_struct_10___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_10___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_8___iter__(PyObject *o) {
- struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__ *)o;
+static int __pyx_tp_clear_5_cdec___pyx_scope_struct_10___iter__(PyObject *o) {
+ struct __pyx_obj_5_cdec___pyx_scope_struct_10___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_10___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);
@@ -12389,11 +13933,11 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_8___iter__(PyObject *o) {
return 0;
}
-static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_8___iter__[] = {
+static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_10___iter__[] = {
{0, 0, 0, 0}
};
-static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_8___iter__ = {
+static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_10___iter__ = {
0, /*nb_add*/
0, /*nb_subtract*/
0, /*nb_multiply*/
@@ -12451,7 +13995,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_8___iter__ = {
#endif
};
-static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_8___iter__ = {
+static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_10___iter__ = {
0, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
@@ -12464,13 +14008,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_8___iter__ = {
0, /*sq_inplace_repeat*/
};
-static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_8___iter__ = {
+static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_10___iter__ = {
0, /*mp_length*/
0, /*mp_subscript*/
0, /*mp_ass_subscript*/
};
-static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_8___iter__ = {
+static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_10___iter__ = {
#if PY_MAJOR_VERSION < 3
0, /*bf_getreadbuffer*/
#endif
@@ -12491,12 +14035,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_8___iter__ = {
#endif
};
-static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_8___iter__ = {
+static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_10___iter__ = {
PyVarObject_HEAD_INIT(0, 0)
- __Pyx_NAMESTR("_cdec.__pyx_scope_struct_8___iter__"), /*tp_name*/
- sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_8___iter__), /*tp_basicsize*/
+ __Pyx_NAMESTR("_cdec.__pyx_scope_struct_10___iter__"), /*tp_name*/
+ sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_10___iter__), /*tp_basicsize*/
0, /*tp_itemsize*/
- __pyx_tp_dealloc_5_cdec___pyx_scope_struct_8___iter__, /*tp_dealloc*/
+ __pyx_tp_dealloc_5_cdec___pyx_scope_struct_10___iter__, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
@@ -12506,24 +14050,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_8___iter__ = {
0, /*reserved*/
#endif
0, /*tp_repr*/
- &__pyx_tp_as_number___pyx_scope_struct_8___iter__, /*tp_as_number*/
- &__pyx_tp_as_sequence___pyx_scope_struct_8___iter__, /*tp_as_sequence*/
- &__pyx_tp_as_mapping___pyx_scope_struct_8___iter__, /*tp_as_mapping*/
+ &__pyx_tp_as_number___pyx_scope_struct_10___iter__, /*tp_as_number*/
+ &__pyx_tp_as_sequence___pyx_scope_struct_10___iter__, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping___pyx_scope_struct_10___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_8___iter__, /*tp_as_buffer*/
+ &__pyx_tp_as_buffer___pyx_scope_struct_10___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_8___iter__, /*tp_traverse*/
- __pyx_tp_clear_5_cdec___pyx_scope_struct_8___iter__, /*tp_clear*/
+ __pyx_tp_traverse_5_cdec___pyx_scope_struct_10___iter__, /*tp_traverse*/
+ __pyx_tp_clear_5_cdec___pyx_scope_struct_10___iter__, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
- __pyx_methods_5_cdec___pyx_scope_struct_8___iter__, /*tp_methods*/
+ __pyx_methods_5_cdec___pyx_scope_struct_10___iter__, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
0, /*tp_base*/
@@ -12533,7 +14077,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_8___iter__ = {
0, /*tp_dictoffset*/
0, /*tp_init*/
0, /*tp_alloc*/
- __pyx_tp_new_5_cdec___pyx_scope_struct_8___iter__, /*tp_new*/
+ __pyx_tp_new_5_cdec___pyx_scope_struct_10___iter__, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
@@ -12573,7 +14117,19 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
{&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
{&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
+ {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0},
+ {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 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_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0},
+ {&__pyx_kp_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 0},
+ {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
+ {&__pyx_kp_s_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_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0},
+ {&__pyx_kp_s_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 0, 1, 0},
+ {&__pyx_kp_s_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 1, 0},
+ {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0},
{&__pyx_n_s__BLEU, __pyx_k__BLEU, sizeof(__pyx_k__BLEU), 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},
@@ -12591,6 +14147,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s__beam_alpha, __pyx_k__beam_alpha, sizeof(__pyx_k__beam_alpha), 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__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__encode, __pyx_k__encode, sizeof(__pyx_k__encode), 0, 0, 1, 1},
@@ -12600,18 +14157,25 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s__evaluator, __pyx_k__evaluator, sizeof(__pyx_k__evaluator), 0, 0, 1, 1},
{&__pyx_n_s__grammar, __pyx_k__grammar, sizeof(__pyx_k__grammar), 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__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__label, __pyx_k__label, sizeof(__pyx_k__label), 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, __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__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__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__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
{&__pyx_n_s__strip, __pyx_k__strip, sizeof(__pyx_k__strip), 0, 0, 1, 1},
{&__pyx_n_s__utf8, __pyx_k__utf8, sizeof(__pyx_k__utf8), 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) {
@@ -12623,7 +14187,7 @@ static int __Pyx_InitCachedBuiltins(void) {
__pyx_builtin_eval = __Pyx_GetName(__pyx_b, __pyx_n_s__eval); if (!__pyx_builtin_eval) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 105; __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[3]; __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[3]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_builtin_open = __Pyx_GetName(__pyx_b, __pyx_n_s__open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __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 = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
return 0;
__pyx_L1_error:;
return -1;
@@ -12801,6 +14365,59 @@ static int __Pyx_InitCachedConstants(void) {
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_18));
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":65
+ * 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_25 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 65; __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_INCREF(((PyObject *)__pyx_kp_s_24));
+ PyTuple_SET_ITEM(__pyx_k_tuple_25, 1, ((PyObject *)__pyx_kp_s_24));
+ __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_24));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":59
+ *
+ * def todot(self):
+ * def lines(): # <<<<<<<<<<<<<<
+ * yield 'digraph lattice {'
+ * yield 'rankdir = LR;'
+ */
+ __pyx_k_tuple_28 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_28)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_28);
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__i));
+ PyTuple_SET_ITEM(__pyx_k_tuple_28, 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_28, 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_28, 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_28, 3, ((PyObject *)__pyx_n_s__delta));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__delta));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_28));
+ __pyx_k_codeobj_29 = (PyObject*)__Pyx_PyCode_New(0, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_30, __pyx_n_s__lines, 59, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_29)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":68
+ * yield '%d [shape=doublecircle]' % len(self)
+ * yield '}'
+ * return '\n'.join(lines()).encode('utf8') # <<<<<<<<<<<<<<
+ */
+ __pyx_k_tuple_32 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_32)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_32);
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
+ PyTuple_SET_ITEM(__pyx_k_tuple_32, 0, ((PyObject *)__pyx_n_s__utf8));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_32));
+
/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":6
* cdef bytes ret
* if isinstance(sentence, unicode):
@@ -12808,71 +14425,85 @@ static int __Pyx_InitCachedConstants(void) {
* elif isinstance(sentence, str):
* ret = sentence
*/
- __pyx_k_tuple_20 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_20);
+ __pyx_k_tuple_34 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_34)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_34);
__Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
- PyTuple_SET_ITEM(__pyx_k_tuple_20, 0, ((PyObject *)__pyx_n_s__utf8));
+ PyTuple_SET_ITEM(__pyx_k_tuple_34, 0, ((PyObject *)__pyx_n_s__utf8));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_20));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_34));
+
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":89
+ * 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_36 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_36)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_36);
+ __Pyx_INCREF(((PyObject *)__pyx_kp_s_35));
+ PyTuple_SET_ITEM(__pyx_k_tuple_36, 0, ((PyObject *)__pyx_kp_s_35));
+ __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_35));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_36));
- /* "_cdec.pyx":31
+ /* "_cdec.pyx":47
*
* def read_weights(self, cfg):
* with open(cfg) as fp: # <<<<<<<<<<<<<<
* for line in fp:
* fname, value = line.split()
*/
- __pyx_k_tuple_21 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_21);
+ __pyx_k_tuple_38 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_38);
__Pyx_INCREF(Py_None);
- PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, Py_None);
+ PyTuple_SET_ITEM(__pyx_k_tuple_38, 0, Py_None);
__Pyx_GIVEREF(Py_None);
__Pyx_INCREF(Py_None);
- PyTuple_SET_ITEM(__pyx_k_tuple_21, 1, Py_None);
+ PyTuple_SET_ITEM(__pyx_k_tuple_38, 1, Py_None);
__Pyx_GIVEREF(Py_None);
__Pyx_INCREF(Py_None);
- PyTuple_SET_ITEM(__pyx_k_tuple_21, 2, Py_None);
+ PyTuple_SET_ITEM(__pyx_k_tuple_38, 2, Py_None);
__Pyx_GIVEREF(Py_None);
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_38));
- /* "_cdec.pyx":38
+ /* "_cdec.pyx":54
* def translate(self, sentence, grammar=None):
* if isinstance(sentence, unicode):
* inp = sentence.strip().encode('utf8') # <<<<<<<<<<<<<<
* elif isinstance(sentence, str):
* inp = sentence.strip()
*/
- __pyx_k_tuple_22 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_22);
+ __pyx_k_tuple_39 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_39);
__Pyx_INCREF(((PyObject *)__pyx_n_s__utf8));
- PyTuple_SET_ITEM(__pyx_k_tuple_22, 0, ((PyObject *)__pyx_n_s__utf8));
+ PyTuple_SET_ITEM(__pyx_k_tuple_39, 0, ((PyObject *)__pyx_n_s__utf8));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8));
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_22));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_39));
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":140
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":153
* return self.name.c_str()
*
* BLEU = Scorer('IBM_BLEU') # <<<<<<<<<<<<<<
* TER = Scorer('TER')
*/
- __pyx_k_tuple_24 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_24)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_24);
+ __pyx_k_tuple_41 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_41)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_41);
__Pyx_INCREF(((PyObject *)__pyx_n_s__IBM_BLEU));
- PyTuple_SET_ITEM(__pyx_k_tuple_24, 0, ((PyObject *)__pyx_n_s__IBM_BLEU));
+ PyTuple_SET_ITEM(__pyx_k_tuple_41, 0, ((PyObject *)__pyx_n_s__IBM_BLEU));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__IBM_BLEU));
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_24));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_41));
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":141
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":154
*
* BLEU = Scorer('IBM_BLEU')
* TER = Scorer('TER') # <<<<<<<<<<<<<<
*/
- __pyx_k_tuple_25 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_k_tuple_25);
+ __pyx_k_tuple_42 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_42)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_42);
__Pyx_INCREF(((PyObject *)__pyx_n_s__TER));
- PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, ((PyObject *)__pyx_n_s__TER));
+ PyTuple_SET_ITEM(__pyx_k_tuple_42, 0, ((PyObject *)__pyx_n_s__TER));
__Pyx_GIVEREF(((PyObject *)__pyx_n_s__TER));
- __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_42));
__Pyx_RefNannyFinishContext();
return 0;
__pyx_L1_error:;
@@ -12968,20 +14599,20 @@ PyMODINIT_FUNC PyInit__cdec(void)
if (PyType_Ready(&__pyx_type_5_cdec_Lattice) < 0) {__pyx_filename = __pyx_f[3]; __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[3]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec_Lattice = &__pyx_type_5_cdec_Lattice;
- if (PyType_Ready(&__pyx_type_5_cdec_Candidate) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "Candidate", (PyObject *)&__pyx_type_5_cdec_Candidate) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec_Candidate) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "Candidate", (PyObject *)&__pyx_type_5_cdec_Candidate) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 22; __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[4]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "SufficientStats", (PyObject *)&__pyx_type_5_cdec_SufficientStats) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec_SufficientStats) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "SufficientStats", (PyObject *)&__pyx_type_5_cdec_SufficientStats) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __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[4]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "CandidateSet", (PyObject *)&__pyx_type_5_cdec_CandidateSet) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec_CandidateSet) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "CandidateSet", (PyObject *)&__pyx_type_5_cdec_CandidateSet) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __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[4]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "SegmentEvaluator", (PyObject *)&__pyx_type_5_cdec_SegmentEvaluator) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec_SegmentEvaluator) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "SegmentEvaluator", (PyObject *)&__pyx_type_5_cdec_SegmentEvaluator) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 103; __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[4]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "Scorer", (PyObject *)&__pyx_type_5_cdec_Scorer) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5_cdec_Scorer) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "Scorer", (PyObject *)&__pyx_type_5_cdec_Scorer) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec_Scorer = &__pyx_type_5_cdec_Scorer;
if (PyType_Ready(&__pyx_type_5_cdec_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __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 = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -13000,34 +14631,38 @@ PyMODINIT_FUNC PyInit__cdec(void)
__pyx_ptype_5_cdec___pyx_scope_struct_5_sample = &__pyx_type_5_cdec___pyx_scope_struct_5_sample;
if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_6___iter__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5_cdec___pyx_scope_struct_6___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_6___iter__;
- if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_7___iter__) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 45; __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___iter__) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_ptype_5_cdec___pyx_scope_struct_8___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_8___iter__;
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_7_todot) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec___pyx_scope_struct_7_todot = &__pyx_type_5_cdec___pyx_scope_struct_7_todot;
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_8_lines) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec___pyx_scope_struct_8_lines = &__pyx_type_5_cdec___pyx_scope_struct_8_lines;
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_9___iter__) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec___pyx_scope_struct_9___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_9___iter__;
+ if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_10___iter__) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_5_cdec___pyx_scope_struct_10___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_10___iter__;
/*--- Type import code ---*/
/*--- Variable import code ---*/
/*--- Function import code ---*/
/*--- Execution code ---*/
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":140
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":153
* return self.name.c_str()
*
* BLEU = Scorer('IBM_BLEU') # <<<<<<<<<<<<<<
* TER = Scorer('TER')
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_24), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_41), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s__BLEU, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s__BLEU, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":141
+ /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":154
*
* BLEU = Scorer('IBM_BLEU')
* TER = Scorer('TER') # <<<<<<<<<<<<<<
*/
- __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_42), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s__TER, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s__TER, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "_cdec.pyx":11
@@ -13450,6 +15085,10 @@ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
+static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
+ PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
+}
+
static double __Pyx__PyObject_AsDouble(PyObject* obj) {
PyObject* float_value;
if (Py_TYPE(obj)->tp_as_number && Py_TYPE(obj)->tp_as_number->nb_float) {
@@ -13627,6 +15266,365 @@ 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
+}
+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_PyCFunction_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 (PyType_Ready(&__pyx_CyFunctionType_type) < 0)
+ return -1;
+ __pyx_CyFunctionType = &__pyx_CyFunctionType_type;
+ return 0;
+}
+void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects)
+{
+ __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 void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple)
+{
+ __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
+ m->defaults_tuple = tuple;
+ Py_INCREF(tuple);
+}
+
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;
diff --git a/python/src/_cdec.pyx b/python/src/_cdec.pyx
index 6fafbbc0..cccfec0b 100644
--- a/python/src/_cdec.pyx
+++ b/python/src/_cdec.pyx
@@ -14,7 +14,7 @@ class ParseFailed(Exception): pass
cdef class Decoder:
cdef decoder.Decoder* dec
- cdef public DenseVector weights
+ cdef DenseVector weights
def __cinit__(self, char* config):
decoder.register_feature_functions()
@@ -27,6 +27,22 @@ cdef class Decoder:
def __dealloc__(self):
del self.dec
+ property weights:
+ def __get__(self):
+ return self.weights
+
+ def __set__(self, weights):
+ 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)
+ elif isinstance(weights, dict):
+ for fname, fval in weights.items():
+ self.weights[fname] = fval
+ else:
+ raise TypeError('cannot initialize weights with %s' % type(weights))
+
def read_weights(self, cfg):
with open(cfg) as fp:
for line in fp:
diff --git a/python/src/lattice.pxi b/python/src/lattice.pxi
index 493c6dcd..f8341e29 100644
--- a/python/src/lattice.pxi
+++ b/python/src/lattice.pxi
@@ -54,3 +54,15 @@ cdef class Lattice:
def __dealloc__(self):
del self.lattice
+
+ def todot(self):
+ def lines():
+ yield 'digraph lattice {'
+ 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('"', '\\"'))
+ yield '%d [shape=doublecircle]' % len(self)
+ yield '}'
+ return '\n'.join(lines()).encode('utf8')
diff --git a/python/src/mteval.pxi b/python/src/mteval.pxi
index 9afb6fe1..d90eb9a6 100644
--- a/python/src/mteval.pxi
+++ b/python/src/mteval.pxi
@@ -10,6 +10,15 @@ cdef char* as_str(sentence, error_msg='Cannot convert type %s to str'):
raise TypeError(error_msg % type(sentence))
return ret
+cdef SufficientStats as_stats(x, y):
+ if isinstance(x, SufficientStats):
+ return x
+ elif x == 0 and isinstance(y, SufficientStats):
+ stats = SufficientStats()
+ stats.stats = new mteval.SufficientStats()
+ stats.metric = (<SufficientStats> y).metric
+ return stats
+
cdef class Candidate:
cdef mteval.Candidate* candidate
cdef public float score
@@ -50,10 +59,12 @@ cdef class SufficientStats:
self.stats[0] += other.stats[0]
return self
- def __add__(SufficientStats x, SufficientStats y):
+ 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(x.stats[0], y.stats[0]))
- result.metric = x.metric
+ result.stats = new mteval.SufficientStats(mteval.add(sx.stats[0], sy.stats[0]))
+ result.metric = sx.metric
return result
cdef class CandidateSet:
@@ -73,7 +84,9 @@ cdef class CandidateSet:
def __len__(self):
return self.cs.size()
- def __getitem__(self, unsigned k):
+ 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]
candidate.score = self.metric.ComputeScore(self.cs[0][k].eval_feats)
diff --git a/python/src/vectors.pxi b/python/src/vectors.pxi
index fc0c365f..ce95968c 100644
--- a/python/src/vectors.pxi
+++ b/python/src/vectors.pxi
@@ -80,6 +80,12 @@ cdef class SparseVector:
def __contains__(self, char* fname):
return self.vector.nonzero(FDConvert(fname))
+
+ def __neg__(self):
+ cdef SparseVector result = SparseVector()
+ result.vector = new FastSparseVector[weight_t](self.vector[0])
+ result.vector[0] *= -1.0
+ return result
def __iadd__(SparseVector self, SparseVector other):
self.vector[0] += other.vector[0]